What is CPU scheduling?
"It is a process of determining which process will own CPU to run while the execution of another process is on hold,that means in waiting state due to unavailability of any resource like I/O etc., thereby maximizing utilization of CPU.”
"It is a process of determining which process will own CPU to run while the execution of another process is on hold,that means in waiting state due to unavailability of any resource like I/O etc., thereby maximizing utilization of CPU.”
OBJECTIVES OF PROCESS SCHEDULING ALGORITHM ARE:
- Keep CPU as busy as possible
- Fair allocation of CPU
- Max throughput: Number of processes that complete their execution per time unit
- Min turnaround time: Time taken by a process to finish execution
- Min waiting time: Time a process waits in ready queue
- Min response time: Time when a process produces first response.
ROUND-ROBIN SCHEDULING:-
i. Each process is assigned a fixed time in cyclic way.
ii. The round-robin (RR)scheduling algorithm is designed especially for timesharing systems.
iii. It is similar to FCFS scheduling, but preemption is added to switch between processes.
iv. A small unit of time, called a time quantum (or time slice),is defined. A time quantum is generally from10 to100 milliseconds.
v. The ready queue is treated as a circular queue. The CPU scheduler goes around the ready queue, allocating the CPU to each process for a time interval of up to 1 time quantum.
vi. To implement RR scheduling, we keep the ready queue as a FIFO queue of processes. New processes are added to the tail of the ready queue.
ii. The round-robin (RR)scheduling algorithm is designed especially for timesharing systems.
iii. It is similar to FCFS scheduling, but preemption is added to switch between processes.
iv. A small unit of time, called a time quantum (or time slice),is defined. A time quantum is generally from10 to100 milliseconds.
v. The ready queue is treated as a circular queue. The CPU scheduler goes around the ready queue, allocating the CPU to each process for a time interval of up to 1 time quantum.
vi. To implement RR scheduling, we keep the ready queue as a FIFO queue of processes. New processes are added to the tail of the ready queue.
EXAMPLE ON RR SCHEDULING ALGORITHM:
Quantum time = 20
Process No.
|
Arrival Time
|
Burst Time
|
1
|
0
|
53
|
2
|
0
|
17
|
3
|
0
|
68
|
4
|
0
|
24
|
Total Burst time=162
|
Solution:
Process No
|
Schedule time
|
Completion time
|
Turnaround time
(completion time – arrival time) |
Waiting time
(Turnaround time - burst time) |
Response time
(arrival time – schedule time) |
1
|
0
|
134
|
134
| 81 |
0
|
2
|
20
|
37
|
37
| 20 |
20
|
3
|
37
|
162
|
162
| 94 |
37
|
4
|
57
|
121
|
121
| 97 |
57
|
Average waiting time = (81+20+94+97)/4
=73
Average Turnaround time = (134+37+162+121)/4
=113.5
Average Response time=(0+20+37+57)/4
=28.5
Schedule length = maximum completion time – minimum arrival time
=162-0
=162
=73
Average Turnaround time = (134+37+162+121)/4
=113.5
Average Response time=(0+20+37+57)/4
=28.5
Schedule length = maximum completion time – minimum arrival time
=162-0
=162