4 Process Scheduling
4 Process Scheduling
Basic Concepts
Scheduling Criteria
Scheduling Algorithms
Real-Time Scheduling
Thread Scheduling
Operating Systems Examples
P1 P2 P3
0 24 27 30
Waiting time for P1 = 0; P2 = 24; P3 = 27
Average waiting time: (0 + 24 + 27)/3 = 17
P2 P3 P1
0 3 6 30
Waiting time for P1 = 6; P2 = 0; P3 = 3
Average waiting time: (6 + 0 + 3)/3 = 3
Much better than previous case
Convoy effect short process behind long process
Associate with each process the length of its next CPU burst. Use
these lengths to schedule the process with the shortest time
Two schemes:
nonpreemptive – once CPU given to the process it cannot be
preempted until completes its CPU burst
preemptive – if a new process arrives with CPU burst length
less than remaining time of current executing process,
preempt. This scheme is know as the
Shortest-Remaining-Time-First (SRTF)
SJF is optimal – gives minimum average waiting time for a given
set of processes
P1 P3 P2 P4
0 3 7 8 12 16
P1 P2 P3 P2 P4 P1
0 2 4 5 7 11 16
P1 P3 P2 P4
0 3 7 8 12 16
Average waiting time = (0 + 6 + 3 + 7)/4 = 4
P1 P2 P3 P2 P4 P1
0 2 4 5 7 11 16
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
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.
▪ Assume m processes
▪ Each process runs periodically
▪ Process i needs Ci time to finish
▪ Pi: period duration for process i
▪ Necessary condition for all processes
finish on time:
A A1 A2 A3 A4
B B1 B2 B3
C C1 C2 C3
RMS A1 B1 C1 A2 B2 C2 A3 B3 A4 C3
EDF A1 B1 C1 A2 B2 C2 A3 B3 A4 C3
0 10 20 30 40 50 60 70 80 90 100 110
A A1 A2 A3 A4
B B1 B2 B3
C C1 C2 C3
RMS A1 B1 A2 B2 Failed
EDF A1 B1 C1 A2 B2 A3 C2 B3 A4 C3
0 10 20 30 40 50 60 70 80 90 100 110
Solaris scheduling
Windows XP scheduling
Linux scheduling
Real-time
Soft real-time
Posix.1b compliant – two classes
FCFS and RR