2081 10

CSC264 ยท 2081 ยท 5 marks

Calculate the average waiting time and turnaround time using priority algorithm (Priority 1 being the highest) for the given scenario:

Calculate the average waiting time and turnaround time using priority algorithm (Priority 1 being the highest) for the given scenario:

$$\begin{array}{|c|c|c|c|} \hline \text{PID} & \text{Burst Time} & \text{Arrival Time} & \text{Priority} \ \hline A & 3 & 0 & 3 \ B & 2 & 2 & 3 \ C & 4 & 3 & 2 \ D & 2 & 3 & 1 \ \hline \end{array}$$

[5]

Operating SystemsChapter 2: Process ManagementProcess SchedulingNumerical: Priority scheduling algorithmVideo solution

Priority Scheduling (Non-Preemptive) - Average WT and TAT

Given

PIDBurst TimeArrival TimePriority
A303
B223
C432
D231

Priority 1 = highest. Assume non-preemptive priority scheduling.


Solution

Execution Order

  • t = 0: Only A available โ†’ A runs 0 to 3.
  • t = 3: Ready = B (P3), C (P2), D (P1). Highest priority = D โ†’ D runs 3 to 5.
  • t = 5: Ready = B (P3), C (P2). Higher priority = C โ†’ C runs 5 to 9.
  • t = 9: Only B remains โ†’ B runs 9 to 11.

Gantt Chart

| A | D |  C  | B |
0   3   5     9  11

Completion, Turnaround, Waiting Times

TAT = CT โˆ’ AT, WT = TAT โˆ’ BT

PIDATBTCTTAT = CTโˆ’ATWT = TATโˆ’BT
A03330
B221197
C34962
D32520

Averages

$$\text{Avg TAT} = \frac{3 + 9 + 6 + 2}{4} = \frac{20}{4} = 5 \text{ ms}$$

$$\text{Avg WT} = \frac{0 + 7 + 2 + 0}{4} = \frac{9}{4} = 2.25 \text{ ms}$$


Final Result

MetricValue
Average Turnaround Time5 ms
Average Waiting Time2.25 ms

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.