Summarizing presentation of Scheduler Activations – A different approach to parallelism
Scheduler Activations: Effective Kernel Support for the User-Level Management of Parallelism
description
Transcript of Scheduler Activations: Effective Kernel Support for the User-Level Management of Parallelism
CS533 - Concepts of Operating Systems
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
1
CS533 - Concepts of Operating Systems 2
What is User Thread and Kernel Thread
User Level Threads Kernel Level Threadso Implemented in userspace libraries o implemented by kernel or OSo Managed and scheduled in
userspace o Managed and scheduled by kernel
o Exist only in user space and invisible to Kernel
o Kernel can see and schedule
Source: http://siber.cankaya.edu.tr/OperatingSystems/week5/node5.html
CS533 - Concepts of Operating Systems
Kernel Threads
Cons: Too heavyweight Performance is affected by
o System calls needed to perform thread operationso Security checking required for every thread operation in order to
protect kernel from malicious programs. Generic: because used by all the applications causing
overheadPros: Directly scheduled by kernel, hence no system integration
issues
3
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
o Thread management requires no kernel interventiono 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. 4
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.”
5
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.
6
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.o 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.o 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.
7
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.
8
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
9
CS533 - Concepts of Operating Systems
How does it work
10
Processors
Operating System Kernel
User-Level Runtime system
Scheduler Activation
User-Level thread mgmnt
system
User program
Operating System
1 creates
2 Assigns
3 Upcall
Scheduler Activation
Scheduler Activation
Upcall Upcall
7 creates
5 creates
6 more
4 runs
CS533 - Concepts of Operating Systems
Scheduler Activation Upcall Points
11
CS533 - Concepts of Operating Systems
How blocking requests are handled
12
CS533 - Concepts of Operating Systems
Scheduler activation System Calls
13
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?o Poor performanceo Deadlock
How to address this problem?o Prevention
Avoid through the use of scheduling and locking protocols between kernel and user level.
o RecoveryAn 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.
14
CS533 - Concepts of Operating Systems
Implementation
The design was implemented by modifying Topaz (Operating System) and FastThreads (user-level thread package).
Performance Enhancements:o 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.
o Recyclescheduler activation
15
CS533 - Concepts of Operating Systems
Performance
Thread performance: There is no improvement over user-level thread package running on kernel threads
16
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
17
Execution time of N-Body application versus amount of available memory, 6processors.
Speedup of N-Body application versus number of processors, 100% of memory available.
Application performance
CS533 - Concepts of Operating Systems 18
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.
19
CS533 - Concepts of Operating Systems
Other Implementations
Taos Mach and the Mach-inspired Digital Unix It was implemented in the NetBSD kernel by Nathan
Williams but has been abandoned in favor of 1:1 threading. FreeBSD had a similar threading implementation called
Kernel 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
20Source: http://en.wikipedia.org/wiki/Scheduler_activationshttp://web.mit.edu/nathanw/www/usenix/freenix-sa/freenix-sa.html
CS533 - Concepts of Operating Systems 21
CS533 - Concepts of Operating Systems
Thank you!
22