AI InterviewSearch…Search problems, topics, or pages…Ctrl KGet started
Mediumschedulingsjf

~120s

Average waiting time under SJF

Four processes are all present at time 0:

ProcessBurst time
P16
P28
P37
P43

Under non-preemptive shortest-job-first scheduling, what is the average waiting time?

Show the answer and the worked solution

Correct answer: B.

7.00

Worked solution

  1. All four are ready at time 0, so SJF runs them in burst order: P4, P1, P3, P2.
  2. The schedule is P4 from 0 to 3, P1 from 3 to 9, P3 from 9 to 16 and P2 from 16 to 24.
  3. The waiting times are P4 = 0, P1 = 3, P3 = 9 and P2 = 16.
  4. The total is 0 + 3 + 9 + 16 = 28, so the average is 28 / 4 = 7.00 units.

Answer: 7.00.

The idea

SJF provably minimises average waiting time for a fixed set of jobs, which is why it is the benchmark every other algorithm is measured against. Its problem is that burst lengths must be predicted, and long jobs can starve.

Shortcut. Sort the bursts to 3, 6, 7, 8; each delays every job after it, so the total wait is 3 × 3 + 6 × 2 + 7 × 1 = 28, and 28 ÷ 4 = 7.

Common trap. 7.75 runs P1 first because it is listed first and only then goes shortest-first, giving waits 0, 6, 9 and 16, which total 31.

Average waiting time under SJF — Aptitude Question

Average waiting time under SJF: Four processes are all present at time 0: | Process | Burst time |… Answer and worked solution on CodeKairo.

Question

Four processes are all present at time 0:

ProcessBurst time
P16
P28
P37
P43

Under non-preemptive shortest-job-first scheduling, what is the average waiting time?

Options

  1. 5.50
  2. 7.00
  3. 7.75
  4. 8.25
Show the answer and the worked solution

Correct answer: B. 7.00

Worked solution

  1. All four are ready at time 0, so SJF runs them in burst order: P4, P1, P3, P2.
  2. The schedule is P4 from 0 to 3, P1 from 3 to 9, P3 from 9 to 16 and P2 from 16 to 24.
  3. The waiting times are P4 = 0, P1 = 3, P3 = 9 and P2 = 16.
  4. The total is 0 + 3 + 9 + 16 = 28, so the average is 28 / 4 = 7.00 units.

Answer: 7.00.

The idea

SJF provably minimises average waiting time for a fixed set of jobs, which is why it is the benchmark every other algorithm is measured against. Its problem is that burst lengths must be predicted, and long jobs can starve.

Shortcut. Sort the bursts to 3, 6, 7, 8; each delays every job after it, so the total wait is 3 × 3 + 6 × 2 + 7 × 1 = 28, and 28 ÷ 4 = 7.

Common trap. 7.75 runs P1 first because it is listed first and only then goes shortest-first, giving waits 0, 6, 9 and 16, which total 31.

All OS, DBMS & Networks questions · placement mock tests