Week-3 - CPU SCHEDULING
Week-3 - CPU SCHEDULING
CPU Scheduling
Process Scheduling 12-2
Scheduling Queues 12-3
Scheduling Queues 12-4
Context Switch 12-5
Process Scheduling 12-6
CPU scheduling decisions may take place under the following four
circumstances:
1. When a process switches from the running state to the waiting state
(for I/O request or invocation of wait for the termination of one of the
child processes).
2. When a process switches from the running state to the ready state (for
example, when an interrupt occurs).
3. When a process switches from the waiting state to the ready state (for
example, completion of I/O).
4. When a process terminates.
Type of CPU Scheduling 12-10
1. Running to Waiting
2. Running to Ready
3. Waiting to Ready
4. Process Terminate
Type of CPU Scheduling 12-11
Non-Preemptive Scheduling
Under non-preemptive scheduling, once the CPU has been allocated to a
process, the process keeps the CPU until
1. Process is terminated
2. Switches to the waiting state.
Preemptive Scheduling
In this type of Scheduling, the process switches the control to another
process in following conditions
3. High Priority Process Arrives
4. Times Slice Expires
5. Process completes it I/O Operation
6. Generate a child process
CPU Scheduling Criteria 12-12
CPU Utilization: To make out the best use of CPU and not to waste
any CPU cycle, CPU would be working most of the time (Ideally 100%
of the time).
Considering a real system, CPU usage should range from 40% (lightly
loaded) to 90% (heavily loaded).
FCFS Example-Q1 12-14
Average WT=17
Q2 12-15
Average WT=8
Q3 12-16
Average WT=5.75
Q4. 12-17
SJF 12-18
SJF with non-preemptive 12-19
Example 2(Non-preemptive) 12-20
Wait time
P4= 0-0=0
P1= 3-2=1
P2= 9-5=4
P5= 11-4=7
P3= 15-1=14
Average Waiting Time= (0+1+4+7+14)/5 = 26/5 = 5.2
12-22
12-23