lecture-threads

lecture-threads - Threads ByDr.YingwuZhu Chapter4:Threads...

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

View Full Document Right Arrow Icon
    Threads By Dr. Yingwu Zhu
Background image of page 1

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

View Full DocumentRight Arrow Icon
    Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads
Background image of page 2
    Threaded Applications Web browsers: display and data  retrieval Web servers Many others
Background image of page 3

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

View Full DocumentRight Arrow Icon
    Threads What is a thread ? Lightweight Process (LWP)? Basic unit of CPU utilization Contains Thread ID Program counter Register set Stack Why multithreading ? Creating processes are expensive Other advantages
Background image of page 4
    Single and Multithreaded  Processes
Background image of page 5

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

View Full DocumentRight Arrow Icon
    Benefits Responsiveness Resource Sharing   share memory and resources of the process they belong to Sharing code and data allow different threads of activity within the  same address space Economy Processes are expensive to create, and do context-switch In Solaris Process creating is about 30 times slower Context-switch is about 5 times slower Utilization of MP Architectures A single-threaded process can only run on one CPU
Background image of page 6
    Thread Type User threads Kernel threads
Background image of page 7

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

View Full DocumentRight Arrow Icon
    User Threads Thread management (creation, scheduling) done by  user-level threads library No kernel resources allocated to the threads Drawback Blocking system call suspends other threads in the same process Three primary thread libraries:  POSIX Pthreads  Win32 threads  Java threads
Background image of page 8
    Kernel Threads Supported by the Kernel Advantages Non-blocking thread execution  ( Similar to processes, when a kernel  thread makes a blocking call, only that thread blocks  ) Multi-processors (threads on different processors) Drawback Slower to create and manage than user-level Examples Windows XP/2000, Solaris Linux Tru64 UNIX, Mac OS X
Background image of page 9

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

View Full DocumentRight Arrow Icon
    Multithreading Models Many-to-one One-to-one Many-to-many
Background image of page 10
    Many-to-One Many user-level threads mapped to single kernel  thread Thread management is done by thread lib. in user  space; so, it is efficient. But, a thread making a blocking system call block the entire process Multiple threads cannot run in parallel on MP computers (only one thread  can access the kernel at a time) Used on systems that do not support kernel threads. Examples: Solaris Green Threads GNU Portable Threads
Background image of page 11

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

View Full DocumentRight Arrow Icon
    Many-to-One Model
Background image of page 12
    Many-to-one Model Kernels do not support multiple threads of control Multithreading can be implemented entirely as a user- level library Schedule multiple threads onto the process’s single  kernel thread; multiplexing multiple user threads on a  single kernel thread
Background image of page 13

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

View Full DocumentRight Arrow Icon
    Many-to-one (cont.): Benefits Cheap synchronization When a user thread wishes to perform synchronization, the 
Background image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2011 for the course CSSE 250 taught by Professor Dr.yingwuzhu during the Spring '11 term at UH Clear Lake.

Page1 / 53

lecture-threads - Threads ByDr.YingwuZhu Chapter4:Threads...

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

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