200 likes | 299 Views
Process. Process. Process. Scheduler. Scheduler. Scheduler. processor. processor. processor. User-level Multithreading. Two independent schedulers:. User Space. OS Kernel. Process. Process. Process. Scheduler. processor. processor. processor. Kernel-level Multithreading.
E N D
Process Process Process Scheduler Scheduler Scheduler processor processor processor User-level Multithreading • Two independent schedulers: User Space OS Kernel
Process Process Process Scheduler processor processor processor Kernel-level Multithreading • One single scheduler: User Space OS Kernel
Process Process Process Scheduler Scheduler Scheduler processor processor processor Hybrid Multithreading • Two “cooperating” schedulers User Space OS Kernel • Blocking syscalls are still a problem!
Scheduler Activations • First proposed by [Anderson et al. 91] • Idea: cooperation between schedulers should take place in both directions • User scheduler uses system calls • Kernel scheduler should use upcalls! • Upcalls • Notify the user-level of kernel scheduling events • Activations • A new structure to support upcalls (~kernel thread) • As many running activations as processors • Kernel controls activation creation and destruction
CPUtimewasted syscall I/O request interrupt • …rather use the following scheme: CPU used User Space upcall upcall Kernel Space Hardware Scheduler Activations • Instead of User Space Kernel Space Hardware
Working principle • Blocking syscall scenario on 2 processors Process User scheduler
new Working principle • Blocking syscall scenario on 2 processors Process
new Working principle • Blocking syscall scenario on 2 processors Process
Blocking syscall Working principle • Blocking syscall scenario on 2 processors Process
New + blocked Working principle • Blocking syscall scenario on 2 processors Process
I/O completion Working principle • Blocking syscall scenario on 2 processors Process
Unblocked Working principle • Blocking syscall scenario on 2 processors Process
Working principle • Blocking syscall scenario on 2 processors Process
On the cost of preemption • When the kernel preempts an activation • It must inform the user-level scheduler • Why? • a user thread may own a spin-lock! • How? By triggering a preempt upcall • Problems • A preemption may occur at any time • asynchronous context switches • many code sections must be protected e.g. the marcel_yield() function...
blocking syscall registers sp sp On the cost of unblock events thread activation
thread sp Clock int. registers registers blocked sp sp sp sp activation On the cost of unblock events thread activation
thread sp registers registers registers registers sp sp sp activation On the cost of unblock events thread activation
thread sp registers registers registers sp sp activation On the cost of unblock events thread
thread sp jb sp registers registers sys_restart activation On the cost of unblock events thread
thread sp registers activation On the cost of unblock events thread