Threads_Systems_Conc - Review:WhyThreads Copyright University of Illinois CS 241 Staff 1 Tocreateanewthread Toterminateathread

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Copyright ©: University of Il inois CS 241 Staff 1 Threads Systems Concepts Review: Why Threads?  Processes do not share resources very well ± Why? Process context switching cost is very high ± Why? Threads: light-weight processes Copyright ©: University of Il inois CS 241 Staff 2 Benefits of Threads Takes less time  ± To create a new thread  ± To terminate a thread ± To switch between two threads Inter-thread communication without  invoking the kernel Copyright ©: University of Il inois CS 241 Staff 3 We like our Threads … Foreground and background work Asynchronous processing Speed of execution Modular program structure Copyright ©: University of Il inois CS 241 Staff 4 Threads: Lightweight  Processes 5 Copyright ©: University of Il inois CS 241 Staff a) Three processes each with one thread b) One process with three threads Environment (resource) execution Tasks Suitable for Threading Has multiple parallel sub-tasks Some sub-tasks block for potentially  long waits Some sub-tasks use many CPU cycles  Must respond to asynchronous events  Copyright ©: University of Il inois CS 241 Staff 6
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Questions What are the similarities between processes  and threads?  What are the differences between processes  and threads? 7 Copyright ©: University of Il inois CS 241 Staff Thread Packages Kernel thread packages  ± Implemented and supported at kernel  level User-level thread packages ± Implemented at user level ± Kernel perspective: everything is a  single-threaded process 8 Copyright ©: University of Il inois CS 241 Staff Threads in User Space (Old  Linux) Copyright ©: University of Il inois CS 241 Staff 9 Collection of procedures that manages the threads Keep track of threads in process (analogous to kernel process table) User-level Threads Advantages ± Fast Context Switching: keeps the OS out of it! User level thread libraries do not require system calls ± No call to OS and no interrupts to kernel thread_yield  ± Save the thread information in the thread table ± Call the thread scheduler to pick another thread to run Saving local thread state scheduling are local  procedures ± No trap to kernel, low context switch overhead, no memory 
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/10/2011 for the course CS 241 taught by Professor Campbell during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 5

Threads_Systems_Conc - Review:WhyThreads Copyright University of Illinois CS 241 Staff 1 Tocreateanewthread Toterminateathread

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online