OS Ch#5 CPU Scheduling
OS Ch#5 CPU Scheduling
Basic Concepts
Maximum CPU utilization
obtained with
multiprogramming
0 24 27 30
P2 P3 P1
0 3 6 30
0 3 9 16 24
P2 P5 P1 P3 P4
0 1 6 16 18 19
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
CPU scheduling more complex when multiple
CPUs are available
Homogeneous processors within a
multiprocessor
Asymmetric multiprocessing – only one
processor accesses the system data structures,
alleviating the need for data sharing
Symmetric multiprocessing (SMP) – each
processor is self-scheduling, all processes in
common ready queue, or each has its own
private queue of ready processes
Multiple-Processor
Scheduling
Processor affinity – process has affinity for
processor on which it is currently running
soft affinity: When an operating system has a
policy of attempting to keep a process running
on the same processor—but not guaranteeing
that it will do so known as soft affinity.
hard affinity: allowing a process to specify a
subset of processors on which it may run.
Multiple-Processor Scheduling – Load
Balancing