# GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 50

Consider the following set of jobs to be scheduled for execution on a single CPU system.

```Job    Arrival Time    Size (msec)   Priority
J1             0          10         2 (Silver)
J2             2          8          1 (Gold)
J3             3          3          3 (Bronze)
J4            10          4          2 (Silver)
J5            12          1          3 (Bronze)
J6            15          4          1 (Gold) ```

Which of the following is the correct order for scheduling policies providing the lowest waiting time for this set of jobs?
(A) Non-preemptive SJF < FCFS < preemptive priority scheduling < non-preemptive priority scheduling
(B) Non-preemptive SJF < FCFS < preemptive priority scheduling < non-preemptive priority scheduling
(C) Non-preemptive SJF < preemptive priority scheduling < FCFS < non-preemptive priority scheduling
(D) Non-preemptive SJF < preemptive priority scheduling < non-preemptive priority scheduling < FCFS

Explanation: 1. Gantt chart for FCFS scheduling:

```Job    Arrival Time    Size (msec)    Priority   Turn around time  Waiting time
J1             0          10         2 (Silver)     0                 0
J2             2          8          1 (Gold)       16                8
J3             3          3          3 (Bronze)     18                15
J4            10          4          2 (Silver)     15                11
J5            12          1          3 (Bronze)     14                13
J6            15          4          1 (Gold)       15                11```

Average waiting time

`= (0 + 8 + 15 + 11 + 13 + 11) / 6 = 9.67 `

2. Gantt chart for non-preemptive SJF scheduling:

```Job    Arrival Time    Size (msec)    Priority   Turn around time  Waiting time
J1             0          10         2 (Silver)     0                  0
J2             2          8          1 (Gold)       28                 20
J3             3          3          3 (Bronze)     10                 7
J4            10          4          2 (Silver)     8                  4
J5            12          1          3 (Bronze)     2                  1
J6            15          4          1 (Gold)       7                  3```

Average waiting time

`= (0 + 20 + 7 + 4 + 1 + 3) / 6 = 5.83 `

3. Gantt chart for non-preemptive priority scheduling:

```Job    Arrival Time    Size (msec)    Priority   Turn around time  Waiting time
J1             0          10         2 (Silver)     0                 0
J2             2          8          1 (Gold)       16                8
J3             3          3          3 (Bronze)     26               23
J4            10          4          2 (Silver)     16                12
J5            12          1          3 (Bronze)     18                17
J6            15          4          1 (Gold)       15                3```

Average waiting time

`= (0 + 8 + 23 + 12 + 17 + 3) / 6 = 10.5 `

4. Gantt chart for preemptive priority scheduling:

```Job    Arrival Time    Size (msec)    Priority   Turn around time  Waiting time
J1             0          10         2 (Silver)     0                 12
J2             2          8          1 (Gold)       8                 0
J3             3          3          3 (Bronze)     26                3
J4            10          4          2 (Silver)     16                12
J5            12          1          3 (Bronze)     18                17
J6            15          4          1 (Gold)       4                0```

Average waiting time

`= (12 + 0 + 3 + 12 + 17 + 0) / 6 = 7.33 `

Therefore, Non-preemptive SJF < preemptive priority scheduling < FCFS < non-preemptive priority scheduling.

So, option (C) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.