TFCS 5
TFCS 5
▸ Basic Concepts
▸ Scheduling Criteria
▸ Scheduling Algorithms
▸ Thread Scheduling
▸ Multiple-Processor Scheduling
▸ Operating Systems Examples
▸ Algorithm Evaluation
Waiting time – amount of time a process has been waiting in the ready
queue
P1 P2 P3
0 24 27 30
P2 P3 P1
0 3 6 30
P4 P1 P3 P2
0 3 9 16 24
▸ Average waiting time = (3 + 16 + 9 + 0) / 4 = 7
The CPU is allocated to the process with the highest priority (smallest integer highest
priority)
Preemptive
Nonpreemptive
P2 P5 P1 P3 P4
0 1 6 16 18 19
Average waiting time = 8.2 msec
Each process gets a small unit of CPU time (time quantum q),
usually 10-100 milliseconds. After this time has elapsed, the
process is preempted and added to the end of the ready
queue.
Timer interrupts every quantum to schedule next process
Performance
q large FIFO
q small q must be large with respect to context switch,
otherwise overhead is too high
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
▸ 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