MODULE 2 - Process and Scheduling
MODULE 2 - Process and Scheduling
SJF is priority scheduling where priority is the inverse of predicted next CPU
burst time
Problem Starvation – low priority processes may never execute
Solution Aging – as time progresses increase the priority of the process
Example of Priority Scheduling
Round Robin (RR)
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.
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.
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
Example of RR with Time Quantum = 4
Time Quantum and Context Switch Time
Multilevel Queue
Ready queue is partitioned into separate queues, eg:
foreground (interactive)
background (batch)
Process permanently in a given queue
Each queue has its own scheduling algorithm:
foreground – RR
background – FCFS
Scheduling must be done between the queues:
Fixed priority scheduling; (i.e., serve all from foreground then from background).
Possibility of starvation.
Time slice – each queue gets a certain amount of CPU time which it can schedule amongst
its processes; i.e., 80% to foreground in RR
20% to background in FCFS
Multilevel Queue Scheduling
Multilevel Feedback Queue
A process can move between the various queues; aging can be
implemented this way
Multilevel-feedback-queue scheduler defined by the following parameters:
number of queues
scheduling algorithms for each queue
method used to determine when to upgrade a process
method used to determine when to demote a process
method used to determine which queue a process will enter when that process
needs service
Example of Multilevel Feedback Queue
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