0
votes

Calculate the waiting time for process P2 using priority based non preemptive scheduling algorithm.

        Process     Execution Time     Arrival Time      Priority
          P1           4                 0                 0
          P2           1                 1                 2
          P3           3                 2                 1

1). According to this algorithm, P1 has the highest priority 0 and it arrives first too. So the time slot for this is allocated as '4' units.

2). Next, does Process3(P3) get executed first? Gannt chart:

               | P1 | P3 | P2 |
               0    4    7    8

Or, is it the other way around?

               | P1 | P2 | P3 |
               0    4    5    8

Is the arrival time of no importance in this procedure?

Thanks!

2
I would guess that, in a "priority based non-preemptive scheduling algorithm", the arrival time would only matter in the sense that a higher priority task that has not arrived yet will not be scheduled before a lower priority one that has. Which is not the case in this particular example... By the time P1 has finished, both P2 and P3 are in queue...twalberg

2 Answers

0
votes

Arrival time is important in this procedure , but first of all you need to be know whether 1 is highest priority or 2 is higher priority If 1 has higher priority then processes will be executed in following order P1---> P3----> P2 (case first) If 2 has higher priority then processes will be executed in following order P1--->P2---->P3 (case second)

Arrival time is also important here because as soon as process 0 finishes up , scheduler has to decide which process has to be executed , as in this case after 4 interals both the processes are availabel for execution , so scheduler will decide based up on the priority, whether 1 is being higher or 2 In case if p0 has taken only execution time as 1 , in that case arrival or priority doesnt hold any significance , as only p1 is available for execution , and scheduler doesnt have to schedule anything

0
votes

for finding waiting time we have to find its gantt chart first. 1)-GANTT CHART- |p1|p2|p3| 0 4 5 8

2)-waiting time of p2 is----------------> 4-1 =3 when the arrival time is given, then wating time=waiting time in gantt chart-arrival time. because when the process is arrived then start wait for process.so the waiting time start from when process arrived.