Saturday 6 June 2015

Q46,paper 2, D13.



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
ArrivalTime
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
(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

following processes want to execute :
Process ID
ArrivalTime
Service time
P1
0
 4
P2
1
1
P3
2
2
P4
3
1
Time               Priority
0                     p1=1,
1                     p2=1,p1=2.
2                     P2=2,p1=2,p3=0
3                     P1=1,p3=2,p4=0
4                     P3=1,p1=2,p4=2
5                     P1=1,p3=2,p4=2
 Gantt chart
0----p1---1-----p2----2-----p1-----3------p3---4--—p4—5----p1-----6------p3------7  -----p1----8.
P1 finishes at 8.
P2 at 2
P3 at 7
P4 at 5.


2 comments:

  1. Could you please explain the calculation of priority of each process at different time.

    ReplyDelete

Note: only a member of this blog may post a comment.