- Asked 2/19
- 2070 Bhadra · 3 marks
- 2075 Baisakh · 5 marks
Non-preemptive SJF with P4 arriving
Short answer
Non-preemptive SJF selects shortest burst when CPU free. Schedule: P3(0-2), P4(2-6), P1(6-12), P2(12-20). Waiting times: P1=6ms, P2=12ms, P3=0ms, P4=1ms; average=4.75ms. Turnaround times: P1=12ms, P2=20ms, P3=2ms, P4=5ms; average=9.75ms.
Three processes with process IDs P1, P2, P3 with estimated completion times 6, 8, 2 milliseconds respectively enter the ready queue together (in the order P1, P2, P3). Process P4 with estimated execution completion time 4 milliseconds enters the ready queue after 1 millisecond. Calculate the waiting time and turn-around-time (TAT) for each process and the average waiting time and TAT in the non-preemptive shortest-job-first scheduling.
Non-preemptive SJF: when the CPU becomes free, the ready process with the shortest burst time is selected, and it runs until it finishes. Waiting time (WT) = start time - arrival time; turnaround time (TAT) = completion time - arrival time = WT + burst time.
| Process | Arrival (ms) | Burst (ms) |
|---|---|---|
| P1 | 0 | 6 |
| P2 | 0 | 8 |
| P3 | 0 | 2 |
| P4 | 1 | 4 |
Schedule
- t = 0: P1, P2, P3 are ready, the shortest is P3 (2 ms), so P3 runs from 0 to 2 (it cannot be interrupted when P4 arrives at t = 1).
- t = 2: P1 (6), P2 (8), P4 (4) are ready, the shortest is P4: runs 2 to 6.
- t = 6: P1 (6) then P2 (8): P1 runs 6 to 12.
- t = 12: P2 runs 12 to 20.
| P3 | P4 | P1 | P2 |
0 2 6 12 20
| Process | Completion | TAT = CT - AT | WT = TAT - Burst |
|---|---|---|---|
| P1 | 12 | 12 - 0 = 12 | 12 - 6 = 6 |
| P2 | 20 | 20 - 0 = 20 | 20 - 8 = 12 |
| P3 | 2 | 2 - 0 = 2 | 2 - 2 = 0 |
| P4 | 6 | 6 - 1 = 5 | 5 - 4 = 1 |
Average WT = (6 + 12 + 0 + 1) / 4 = 19 / 4 = 4.75 ms Average TAT = (12 + 20 + 2 + 5) / 4 = 39 / 4 = 9.75 ms
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Preemptive priority scheduling with P4 (6 ms) · Embedded System, chapter 6 · asked 2×
- Preemptive SJF/SRT scheduling (10, 5, 7 ms) · Embedded System, chapter 6
- Non-preemptive priority scheduling (10, 5, 7 ms) · Embedded System, chapter 6 · asked 2×
- Priority and SJF scheduling with P4 and P5 · Embedded System, chapter 6 · asked 2×
- Priority scheduling (7, 8, 5 ms) with P4 · Embedded System, chapter 6 · asked 2×
- Preemptive priority scheduling (4, 6, 5 ms) · Embedded System, chapter 6
- RR, preemptive priority, preemptive SJF · Operating System, chapter 2
- Preemptive priority and SRTF Gantt · Operating System, chapter 2
- FCFS, SJF, Priority, RR Gantt; max AWT · Operating System, chapter 2
- Real-time scheduling; two-processor numerical · Operating System, chapter 2