270 likes | 487 Views
Scheduler Activations: Effective Kernel Support for the User-Level Management of Parallelism. THOMAS E. ANDERSON, BRIAN N. BERSHAD, EDWARD D. , LAZOWSKA, and HENRY M. LEVY University of Washington Presenter: Neena Maldikar. What is User Thread and Kernel Thread.
E N D
Scheduler Activations: Effective Kernel Support for the User-Level Management of Parallelism THOMAS E. ANDERSON, BRIAN N. BERSHAD, EDWARD D. , LAZOWSKA, and HENRY M. LEVY University of Washington Presenter: Neena Maldikar CS533 - Concepts of Operating Systems
What is User Thread and Kernel Thread CS533 - Concepts of Operating Systems Source: http://siber.cankaya.edu.tr/OperatingSystems/week5/node5.html
Kernel Threads Cons: • Too heavyweight • Performance is affected by • System calls needed to perform thread operations • Security checking required for every thread operation in order to protect kernel from malicious programs. • Generic: because used by all the applications causing overhead Pros: • Directly scheduled by kernel, hence no system integration issues CS533 - Concepts of Operating Systems
User Threads Pros: • Lightweight since at the user level, each application needs only the minimal amount of context saved with it, • Excellent performance because • Thread management requires no kernel intervention • No threat of corrupting Operating System • Different applications can have different thread libraries. Hence, the functionality can be specific to the application. Cons: • Do not have same level of integration with system services as is available with kernel threads. • Can exhibit incorrect behavior in case of multiprogramming, I/O or pagefaults. CS533 - Concepts of Operating Systems
Dilemma “employ user-level threads, which have good performance and correct behavior provided the application is uni-programmed and does no I/O, or employ kernel threads, which have worse performance but are not as restricted.” CS533 - Concepts of Operating Systems
Goal Describe a kernel interface and a user-level thread package that together combine the functionality of kernel threads with the performance and flexibility of user-level threads. CS533 - Concepts of Operating Systems
Why Kernel threads are the wrong abstraction for supporting user-level thread management? • Kernel threads block, resume, and are preempted without notification to the user level. • If user level thread blocks on I/O, kernel thread blocks and an application can run out of kernel threads • Kernel threads are not scheduled with respect to the user-level thread state. • E.g. consider that only one job is running in the system and it is using all the processors. If a new job comes in, operating system decides which threads to preempt. It can preempt a thread holding lock. CS533 - Concepts of Operating Systems
Effective Kernel support for user-level threads • The kernel allocates virtual processors to address spaces • Each address space’s user-level thread system controls which threads to run on its allocated processors. • The kernel notifies the user-level thread system whenever it changes the number of processors assigned to it or when a user-level thread blocks/ wakes up in the kernel. • The user-level thread system notifies the kernel when the application needs more or fewer processors. CS533 - Concepts of Operating Systems
What is Scheduler Activation? Scheduler Activation: • It is a scheme for communication between the kernel and the user-level thread system. • It is an invocation of the user level thread scheduler by the kernel – also known as ‘upcall’. • It is executed on a control flow created by kernel. • It brings along its own CPU either new or the one application was using before (in case of interrupt/ pagefault/ exception). • In the later case, it provides space in the kernel for saving the processor context of the activation's current user-level thread. (This is same as OS interrupt) • This space is provided with two stacks – one mapped into the kernel and the other one into the application address space CS533 - Concepts of Operating Systems
How does it work User program User-Level Runtime system User-Level thread mgmnt system 4 runs 5 creates 6 more Operating System 7 creates Operating System Kernel 3 Upcall Upcall Upcall 1 creates Scheduler Activation Scheduler Activation Scheduler Activation 2 Assigns Processors CS533 - Concepts of Operating Systems
Scheduler Activation Upcall Points CS533 - Concepts of Operating Systems
How blocking requests are handled CS533 - Concepts of Operating Systems
Scheduler activation System Calls An apparent drawback – Applications may not be honest! Solution: Multi-level feedback. The processor allocator can favor the processes the address spaces that use fewer processors and penalize the ones that use more. CS533 - Concepts of Operating Systems
Critical Sections Problem • What if user-level thread is in critical section when it is blocked or preempted? • Poor performance • Deadlock • How to address this problem? • Prevention Avoid through the use of scheduling and locking protocols between kernel and user level. • Recovery An upcall informs the user-level thread system about preemption and the thread system checks if thread was executing in a critical section. If so, it is allowed to continue till by user level context switch. CS533 - Concepts of Operating Systems
Implementation • The design was implemented by modifying Topaz (Operating System) and FastThreads (user-level thread package). • Performance Enhancements: • To avoid overhead of lock acquisition and release, critical section of the each thread is copied and it is executed if the thread is in critical section when the preemption happens. • Recyclescheduler activation CS533 - Concepts of Operating Systems
Performance • Thread performance: There is no improvement over user-level thread package running on kernel threads • Upcall performance: Signal-wait time was found to be 2.4 msec – a factor of five worse than Topaz threads. CS533 - Concepts of Operating Systems
Performance • Application performance Speedup of N-Body application versus number of processors, 100% of memory available. Execution time of N-Body application versus amount of available memory, 6 processors. CS533 - Concepts of Operating Systems
Performance • Multiprogramming performance CS533 - Concepts of Operating Systems
Conclusion • User-level threads are essential for high-performance. • However, kernel threads or processes, as provided in many operating systems, are poor abstraction on which to support user-level threads. • Scheduler activation design can be used to combine the performance of user-level threads and functionality of kernel threads. CS533 - Concepts of Operating Systems
Other Implementations • Taos • Mach and the Mach-inspired Digital Unix • It was implemented in the NetBSD kernel by Nathan Williamsbut has been abandoned in favor of 1:1 threading. • FreeBSD had a similar threading implementation calledKernel Scheduled Entities which is also being retired in favor of 1:1 threading. • Scheduler activations were also implemented as a patch for the Linux kernel by Vincent Danjean: Linux Activations, the user-level part being done in the Marcel thread library CS533 - Concepts of Operating Systems Source: http://en.wikipedia.org/wiki/Scheduler_activations http://web.mit.edu/nathanw/www/usenix/freenix-sa/freenix-sa.html
Thank you! CS533 - Concepts of Operating Systems