Transcript pptx

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
1
What is User Thread and Kernel Thread
User Level Threads
Kernel Level Threads
o
Implemented in userspace libraries
o
implemented by kernel or OS
o
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
CS533 - Concepts of Operating Systems
Source: http://siber.cankaya.edu.tr/OperatingSystems/week5/node5.html
2
Kernel Threads
Cons:
 Too heavyweight
 Performance is affected by
o
o
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
3
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
o
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
4
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
5
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
6
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 userlevel 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.
CS533 - Concepts of Operating Systems
7
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
8
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
9
How does it work
User program
User-Level
Runtime
system
User-Level
thread mgmnt
system
4 runs
5 creates
6 more
Operating
System
Kernel
Operating
System
7 creates
3 Upcall
Upcall
Upcall
1 creates
Scheduler
Activation
Scheduler
Activation
Scheduler
Activation
2 Assigns
Processors
CS533 - Concepts of Operating Systems
10
Scheduler Activation Upcall Points
CS533 - Concepts of Operating Systems
11
How blocking requests are handled
CS533 - Concepts of Operating Systems
12
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
13
Critical Sections Problem

What if user-level thread is in critical section when it is
blocked or preempted?
o
o

Poor performance
Deadlock
How to address this problem?
o
Prevention
Avoid through the use of scheduling and locking protocols between kernel
and user level.
o
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
14
Implementation

The design was implemented by modifying Topaz (Operating
System) and FastThreads (user-level thread package).

Performance Enhancements:
o
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.
Recyclescheduler activation
CS533 - Concepts of Operating Systems
15
Performance

Thread performance: There is no improvement over userlevel 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
16
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
17
Performance

Multiprogramming performance
CS533 - Concepts of Operating Systems
18
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
19
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
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
20
CS533 - Concepts of Operating Systems
21
Thank you!
CS533 - Concepts of Operating Systems
22