Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Example 3. Consider the following set of processes in table below and the follow

ID: 3902417 • Letter: E

Question

Example 3. Consider the following set of processes in table below and the following scheduling algorithm - (a) SJF (b) Shortest Remaining Job First Process id Arrival Time Execution Time 12 If there is a tie within the processes, the tie is broken in favour of the oldest process. ) Draw Gantt Chart and find AWT & TAT for the two algorithms. Comment on your results, which one is better and why? un If the scheduler takes 0.2 units of CPU time in contest switching for the completes job and 0.1 unit of additional CPU time for incomplete jobs for saving their context Calculate the percentage of CPU time wasted in each case. IUPTU, B.Tech (CSE IT) -6 sem, 2005-0

Explanation / Answer

Shortest Job First can be both preemptive and non preemptive. But in the most of the cases it is non preemptive and I am considering the non preemptive case here (no interruption is allowed).

In the SJF the process with the shortest burst time gets executed first.

SHORTEST JOB FIRST (NOM PREEMPTIVE)

GANTT CHART

0                   7       9    12 15 20

Turn Around Time = Completion Time- Arrival Time

Waiting Time = Turnaround Time - Burst Time

    Average Waiting Time = (0+14+7+1+0)/5 = 22/5 unit = 4.4 Unit

Shortest Remaining Time First (Preemptive)

In the SRTF scheduling the process with the least remaining time gets executed prior to other processes.

GANTT CHART

0               1               2                 5               6                8                11              12            15              20

Average Waiting Time = (13+5+0+0+0)/5 Unit = 18/5 Unit = 3.6 Unit

In this case SRTF provides better performance as it provides better Turnaround Time (Lower) and better Waiting Time (lower) than SJF (based on the average value).

Context switches in SJF = 4 (Complete) + 0 (Incomplete)

Context switches in SRTF = 4 (Complete) + 4 (Incomplete)

For context switch when a process completes time taken is = 0.2 unit

For context switch when a process is incomplete time taken is = (0.2+0.1) unit = 0.3 unit

For SJF Total time taken = 20+(0.2*4) unit = 20+0.8 unit = 20.8 unit

CPU wasted time = 0.8 unit

CPU wastage percentage = (0.8/20.8)*100% = 3.85%

For SRTF Total time taken = 20+(0.2*4)+(0.3*4) unit = 20+0.8+1.2 unit = 22 unit

CPU wasted time = (0.8+1.2) unit = 2 unit

CPU wastage percentage = (2/22)*100% = 9.1%

Hope this helps.

A D C E B
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote