MSCIT 4th COMP2115 7,8
MSCIT 4th COMP2115 7,8
MSCIT 4th COMP2115 7,8
Lecture # 7
Lecture Contents
➢ CPU Schedulers
➢ Dispatcher
➢ Scheduling Criteria
➢ Scheduling Techniques(FCFS, SJF, Priority)
P1 P2 P3
0 24 27 30
P2 P3 P1
0 3 6 30
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
Could ask the user
Example of SJF
P4 P1 P3 P2
0 3 9 16 24
P1 P5 P1 P3 P4
2 2
0 1 6 16 18 19
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
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
Process Burst Time
P1 24
P2 3
P3 3
The Gantt chart is:
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30