1
SchedulingIntroduction to Scheduling
• Bursts of CPU usage alternate with periods of I/O wait– a CPU-bound process– an I/O bound process
2
When to Schedule
1. At process creation
2. At process termination
3. At blocking system calls
4. At I/O interrupt
Preemtive and non-preemtive scheduling algorithms
3
Goals of Scheduling
4
Scheduling in Batch Systems (1)
(a) First-come-first-served (FCFS)
(b) Shortest-job-first (SJF) - provably optimal if all jobs are known in advance
(c) Shortest-remaining-time-next (SRTN)
5
Scheduling in Batch Systems (2)
Three level scheduling
6
Scheduling in Interactive Systems (1)
• Round Robin Scheduling(a) list of runnable processes(b) list of runnable processes after B uses up its quantum
Length of quantum:– too short => waste of CPU time– too long => poor response
7
Scheduling in Interactive Systems (2)
A scheduling algorithm with four priority classesStatic and dynamic priority allocations, e.g. 1/f.
8
Scheduling in Interactive Systems (3)
• Multiple queues• Shortest process next; aging (weighted average)• Guaranteed scheduling (1/n)• Lottery scheduling - biased randomness, passing tickets• Fair share scheduling
9
Scheduling in Real-Time Systems
Schedulable real-time system
• Given– m periodic events
– event i occurs within period Pi and requires Ci seconds
• Then the load can only be handled if
1
1m
i
i i
C
P
10
Policy versus Mechanism
• Separate what is allowed to be done with how it is done– a process knows which of its children threads
are important and need priority
• Scheduling algorithm parameterized– mechanism in the kernel
• Parameters filled in by user processes– policy set by user process
11
Thread Scheduling (1)
Possible scheduling of user-level threads• 50-msec process quantum, threads run 5 msec/CPU
burst
Application-specific thread schedulers
12
Thread Scheduling (2)
Possible scheduling of kernel-level threads• 50-msec process quantum• threads run 5 msec/CPU burst
13
UNIX Scheduler
The UNIX scheduler is based on a multilevel queue structure
14
Scheduling in Windows (1)
Mapping of Win32 priorities to Windows 2000 priorities
15
Scheduling in Windows (2)
Windows 2000 supports 32 priorities for threads