Home >>Operating System Tutorial >Operating System Scheduling algorithms
A Process Scheduler schedules various processes that are to be allocated to the CPU based on complex scheduling algorithms. We will discuss six common process scheduling algorithms in this chapter-
They are either non- preemptive or preemptive algorithms. Non-preemptive algorithms are designed to prevent a process from entering the running state before it completes its allocated time, while preemptive scheduling is based on priority where a scheduler will preempt a low-priority running process if a high-priority process enters a ready state.
Wait time of each process is as follows −
Process | Wait Time : Service Time - Arrival Time |
---|---|
P0 | 0 - 0 = 0 |
P1 | 5 - 1 = 4 |
P2 | 8 - 2 = 6 |
P3 | 16 - 3 = 13 |
Average Wait Time: (0+4+6+13) / 4 = 5.75
Given: Table of processes, and their Arrival time, Execution time
Process | Arrival Time | Execution Time | Service Time |
---|---|---|---|
P0 | 0 | 5 | 0 |
P1 | 1 | 3 | 5 |
P2 | 2 | 8 | 14 |
P3 | 3 | 6 | 8 |
Process | Waiting Time |
---|---|
P0 | 0 - 0 = 0 |
P1 | 5 - 1 = 4 |
P2 | 14 - 2 = 12 |
P3 | 8 - 3 = 5 |
Average Wait Time: (0 + 4 + 12 + 5)/4 = 21 / 4 = 5.25
Given: Table of processes, and their Arrival time, Execution time, and priority. Here we are considering 1 is the lowest priority.
Process | Arrival Time | Execution Time | Priority | Service Time |
---|---|---|---|---|
PO | 0 | 5 | 1 | 0 |
P1 | 1 | 3 | 2 | 11 |
P2 | 2 | 8 | 1 | 14 |
P3 | 3 | 6 | 3 | 5 |
Waiting time of each process is as follows −
Process | Waiting Time |
---|---|
P0 | 0 - 0 = 0 |
P1 | 11 - 1 = 10 |
P2 | 14 - 2 = 12 |
P3 | 5 - 3 = 2 |
Average Wait Time: (0 + 10 + 12 + 2)/4 = 24 / 4 = 6
Wait time of each process is as follows −
Process | Wait Time : Service Time - Arrival Time |
---|---|
P0 | (0 - 0) + (12 - 3) = 9 |
P1 | (3 - 1) = 2 |
P2 | (6 - 2) + (14 - 9) + (20 - 17) = 12 |
P3 | (9 - 3) + (17 - 12) = 11 |
Average Wait Time: (9+2+12+11) / 4 = 8.5
Multi - level queues are not an independent algorithm for the scheduling. They make use of other existing algorithms to group and schedule jobs that have similar features.
For eg, CPU-bound jobs in one queue and all I / O-bound jobs in another queue will be scheduled. The Process Scheduler then selects jobs from each queue alternately and assigns them to the CPU based on the algorithm assigned to that queue.