23.
Consider a preemptive priority based scheduling algorithm based on dynamically changing priority. Larger priority number implies higher priority. When the process is waiting for CPU in the ready queue (but not yet started execution), its priority changes at a rate \(a = 2\). When it starts running, its priority changes at a rate \(b = 1\). All the processes are assigned priority value 0 when they enter ready queue. Assume that the following processes want to execute :
| Process ID | Arrival Time | Service Time |
|---|
| P1 | 0 | 4 |
| P2 | 1 | 1 |
| P3 | 2 | 2 |
| P4 | 3 | 1 |
The time quantum \(q = 1\). When two processes want to join ready queue simultaneously, the process which has not executed recently is given priority. The finish time of processes P1, P2, P3 and P4 will respectively be
Exam Year(s)
UGC NET - 2013,
Answer: B
The finish times are 8, 2, 7 and 5. Because every process gets priority 0 whenever it enters the ready queue, each preempted process restarts at 0 and gains 2 per unit of waiting. Ties go to the process that has not run recently.
At t = 1, P1 rejoins with 0 and P2 arrives with 0, so P2 runs and finishes at 2. P1 has waited, so it gets priority 2 at t = 2 and runs until 3. P3 then runs 3 to 4, P4 (waiting from 3) ties with P1 at 4 and runs 4 to 5, finishing at 5. P1 runs 5 to 6, P3 runs 6 to 7 and finishes at 7, and P1 runs 7 to 8 and finishes at 8.
The other options have a different finish time for P2 or give P3 and P4 the wrong way round.