Machine-translated by Google. Questions are authored in English.
Top

Discussion

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 IDArrival TimeService Time
P104
P211
P322
P431

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

  • A.4, 5, 7 and 8
  • B.8, 2, 7 and 5
  • C.2, 5, 7 and 8
  • D.8, 2, 5 and 7

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.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.