lecture-threads

lecture-threads - Threads ByDr.YingwuZhu...

Info iconThis preview shows pages 1–10. 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
    Review Multithreading Models Many-to-one One-to-one Many-to-many
Background image of page 2
    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 3

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  user-level thread lib. checks to see if the thread needs to  block. If a user thread does, the user-level thread lib. enqueues it,  and dequeues another user thread from the lib.’s run queue,  and swithes the active thread. No system calls are required Cheap thread creation The thread lib. need only create a context (i.e., a stack and  registers) and enqueues it in the user-level run queue
Background image of page 4
    Many-to-one (cont.): Benefits Resource efficiency Kernel memory is not wasted on a stack for each user  thread Allows as many thread as VM permits Portability User-level threads packages are implemented entirely with  standard UNIX and POSIX lib. calls
Background image of page 5

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

View Full DocumentRight Arrow Icon
    Many-to-one (cont.): Drawbacks Single-threaded OS interface If a user thread blocks (e.g, blocking system calls), the entire  process blocks and so no other user thread can execute  until the kernel thread (which is blocked in the system call)  becomes available Solution: using nonblocking system calls  Can not utilize MP achitectures Examples: Java, Netscape
Background image of page 6
    One-to-one Model Each user thread has a kernel thread
Background image of page 7

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

View Full DocumentRight Arrow Icon
    One-to-one (cont.): Benefits Scalable parallelism Each kernel thread is a different kernel-schedulable entity;  multiple threads can run concurrently on multiprocessors Multithreaded OS interface When one user thread and its kernel thread block, the other  user threads can continue to execute since their kernel  threads are unaffected
Background image of page 8
    One-to-one (cont.): Drawbacks Expensive synchronization Kernel threads require kernel involvement to be scheduled; 
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 31

lecture-threads - Threads ByDr.YingwuZhu...

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

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