Scheduling
Scheduling
● Basic Concepts
● Scheduling Criteria
● Scheduling Algorithms
● Examples
Objectives
● To introduce CPU scheduling, which is the basis for multi-
programmed operating systems
● Continuous Cycle :
● one process has to wait (I/O)
● Operating system takes the CPU away
● Give CPU to another process
● This pattern continues
● CPU utilization – Ideally the CPU would be busy 100% of the time, so as to
waste 0 CPU cycles. On a real system CPU usage should range from 40%
( lightly loaded ) to 90% ( heavily loaded. )
● Throughput – Number of processes completed per unit time. May range
from 10/second to 1/hour depending on the specific processes.
● Turnaround time
– amount of time to execute a particular process
-- the interval from the time of submission of a process to the time of the
completion.
● Waiting time – Amount of time a process has been waiting in the ready
queue.
( Load average – The average number of processes sitting in the ready
queue waiting their turn to get into the CPU )
● Response time – Amount of time it takes from when a request was
submitted until the first response is produced, not output (for time-sharing
environment)
Scheduling Algorithm Optimization Criteria
P1 P2 P3
0 24 27 30
P2 P3 P1
3
0 3 6
0
Convoy Effect :
P1 P3 P2 P4
0 3 7 8 12 16
P1 P2 P3 P2 P4 P1
0 2 4 5 7 11 16
P1 P2 P4 P1 P3
1 1 2
0 1 5
0 7 6
● Average waiting time = [9+0+5+15+2]/4 = 31/4 = 7.75 ms
Priority Scheduling
● A priority number (integer) is associated with each process
● The CPU is allocated to the process with the highest priority (smallest
integer ≡ highest priority)
● Preemptive
● Non-preemptive
● SJF is priority scheduling where priority is the inverse of predicted next CPU
burst time
● Priority can be defined either internally or externally.
● Factors for internal priority assignment:
4 Time limit, memory requirements, the number or open files etc.
● Factors for external priority assignment:
4 Importance of the process, the type and amount of funds of funds
being paid for computer use, department sponsoring works etc.
Example of Priority Scheduling
ProcessA Burst Time Priority
P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2
● Priority scheduling Gantt Chart
P2 P5 P1 P3 P4
1 1 1
0 1 6
6 8 9
P1 P2 P3 P1 P1 P1 P1 P1
1 1 1 2 2 3
0 4 7
0 4 8 2 6 0
● Scheduling
● A new job enters queue Q0 which is served for RR
4 When it gains CPU, job receives 8 milliseconds
4 If it does not finish in 8 milliseconds, job is moved to queue Q1
● At Q1 job is again served RR and receives 16 additional
milliseconds
4 If it still does not complete, it is preempted and moved to
queue Q2
Multilevel Feedback Queues
End of Chapter 6