ch5 CPU Scheduling
ch5 CPU Scheduling
ch5 CPU Scheduling
► Basic Concepts
► Scheduling Criteria
► Scheduling Algorithms
► Thread Scheduling
► Multiple-Processor Scheduling
► Operating Systems Examples
► Algorithm Evaluation
Objectives
► Max throughput
P1 P2 P3
0 24 27 30
P2 P3 P1
0 3 6 30
► Waiting time for P1 = 6; P2 = 0; P3 = 3
► Associate with each process the length of its next CPU burst. Use
these lengths to schedule the process with the shortest time
► SJF is optimal – gives minimum average waiting time for a given set of
processes
► The difficulty is knowing the length of the next CPU request
Example of SJF
P4 P1 P3 P2
0 3 9 16 24
► The CPU is allocated to the process with the highest priority (smallest
integer ≡ highest priority)
► Preemptive
► No preemptive
► If there are n processes in the ready queue and the time quantum
is q, then each process gets 1/n of the CPU time in chunks of at
most q time units at once. No process waits more than (n-1)q
time units.
► Performance
► q large ⇒ FIFO
► q small ⇒ q must be large with respect to context switch, otherwise
overhead is too high
Example of RR with Time Quantum = 4
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
► Three queues:
► Q0 – RR with time quantum 8 milliseconds
► Q1 – RR time quantum 16 milliseconds
► Q2 – FCFS
► Scheduling
► A new job enters queue Q0 which is served FCFS. When it gains CPU, job
receives 8 milliseconds. If it does not finish in 8 milliseconds, job is
moved to queue Q1.
► At Q1 job is again served FCFS and receives 16 additional milliseconds. If
it still does not complete, it is preempted and moved to queue Q2.
Multiple-Processor Scheduling
► Solaris scheduling
► Windows XP scheduling
► Linux scheduling
End of Lecture