Prof. D.S.R. Murthy OS-6 CPU Scheduling 1
Prof. D.S.R. Murthy OS-6 CPU Scheduling 1
Basic Concepts
Scheduling Criteria
Scheduling Algorithms
FCFS
SJF
Nonpreemptive
Preemptive (SRTF)
Priority
RR
Multilevel Queue
Multilevel Feedback Queue
Multiple-Processor Scheduling
Real-Time Scheduling
4. Terminates Nonpreemptive.
involves:
Switching context.
Switching to user mode.
Jumping to the proper location in the user program to restart that program.
Dispatch latency
Time it takes for the dispatcher to stop one process and start another running.
Throughput
No. of processes completed execution per time unit.
Turnaround time
Amount of time to execute a particular process.
Waiting time
Amount of time a process has been waiting in the ready queue.
Response time
Amount of time it takes to start responding, not output
(for time-sharing environment).
Prof. D.S.R. Murthy OS-6 CPU Scheduling 5
Scheduling Criteria
Optimization Criteria
Maximise
CPU utilization
Throughput
Minimise
Turnaround time
Waiting time
Response time
0 24 27 30
Waiting time for P1 = 0; P2 = 24; P3 = 27
Average waiting time: (0 + 24 + 27) / 3 = 17
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.
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.
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
0 2 4 5 7 11 16
Major Problem
Starvation – low priority processes may never execute.
Solution
Aging – as time progresses increase the priority of the process.
0 1 6 16 18 19
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.
Load sharing
Asymmetric multiprocessing
Only one processor accesses the system data structures,
alleviating the need for data sharing.