Computer Science · Operating Systems · Video solution

25. Consider the following snapshot of a system Calculate AWT&ATAT using SRTF Pre-emptive…

Question

25. Consider the following snapshot of a system Calculate AWT&ATAT using SRTF Pre-emptive Scheduling algorithm.

Answer

AWT=6.5ms,ATAT=12.75msAWT = 6.5 ms, ATAT = 12.75 ms

Concept: SRTF Pre-emptive Scheduling

Step-by-step solution

  1. 1. Gantt Chart (0-1)

    Time 0: P1 arrives • P1 starts execution • Runs for 1 unit

  2. 2. Gantt Chart (1-2)

    Time 1: P2 arrives • P1 remaining: 7 • P2 burst: 4

  3. 3. Gantt Chart (2-3)

    Time 2: P3 arrives • P2 remaining: 3 • P3 burst: 9

  4. 4. Gantt Chart (3-7)

    Time 3: P4 arrives • P2 remaining: 2 • P4 burst: 5

  5. 5. Gantt Chart (7-30)

    P4 (5) runs, completes at 12 • P1 (7) runs, completes at 19 • P3 (9) runs, completes at 28

  6. 6. Calculate Times

    Completion Time (CT) • Turnaround Time (TAT) • Waiting Time (WT)

    TAT=CT−AT,WT=TAT−BT\text{TAT} = \text{CT} - \text{AT}, \text{WT} = \text{TAT} - \text{BT}
  7. 7. Average Times

    Sum all WT, TAT • Divide by N=4

    AWT=264=6.5,ATAT=514=12.75\text{AWT} = \frac{26}{4} = 6.5, \text{ATAT} = \frac{51}{4} = 12.75
  8. 8. Yaad rakho / Key takeaway

    SRTF minimizes average waiting time by pre-empting processes.

Remember

SRTF minimizes average waiting time by pre-empting processes.

Common mistake

Forgetting to pre-empt when a new process arrives with shorter burst time.

Got a doubt like this?

Scan your question and Doubtclip makes a whiteboard video solution for it.