Math

QuestionCalculate the average waiting time for processes P1 (12), P2 (4), P3 (8), P4 (2), and P5 (6) using Shortest-Job-First scheduling.

Studdy Solution

STEP 1

Assumptions1. The processes arrive at the times indicated in the table. . Each process will run for the amount of time listed in the "Burst Time" column.
3. We are using non-preemptive scheduling, which means that once a process starts, it runs to completion before the next process starts.
4. We are using the Shortest-Job-First scheduling algorithm, which means that the process with the shortest burst time will be scheduled next.
5. The waiting time for a process is defined as the time from when the process arrives until it starts executing.

STEP 2

First, we need to sort the processes by their arrival times and burst times. In the Shortest-Job-First scheduling algorithm, the process with the shortest burst time that has arrived is scheduled next.
The sorted table looks like this\begin{tabular}{|c|c|c|} \hline Process & Arrival Time & Burst Time \\ \hline1 &0 &12 \\ \hline2 &2 &4 \\ \hline4 &6 &2 \\ \hline &4 &8 \\ \hline5 &8 &6 \\ \hline\end{tabular}

STEP 3

Now, we calculate the waiting time for each process. The waiting time is the time from when the process arrives until it starts executing.

STEP 4

Calculate the waiting time for1. Since1 is the first process to arrive, its waiting time is0.
Waitingtimefor1=0Waiting\, time\, for\,1 =0

STEP 5

Calculate the waiting time for2.2 arrives at time2, but1 is still executing, so2 has to wait until1 finishes.1 finishes at time12, so the waiting time for2 is12 -2 =10.
Waitingtimefor2=122=10Waiting\, time\, for\,2 =12 -2 =10

STEP 6

Calculate the waiting time for4.4 arrives at time6, but2 is still executing, so4 has to wait until2 finishes.2 finishes at time16 (12 +4), so the waiting time for4 is16 -6 =10.
Waitingtimefor4=166=10Waiting\, time\, for\,4 =16 -6 =10

STEP 7

Calculate the waiting time for3.3 arrives at time4, but4 is still executing, so3 has to wait until4 finishes.4 finishes at time18 (16 +2), so the waiting time for3 is18 -4 =14.
Waitingtimefor3=184=14Waiting\, time\, for\,3 =18 -4 =14

STEP 8

Calculate the waiting time for5.5 arrives at time8, but3 is still executing, so5 has to wait until3 finishes.3 finishes at time26 (18 +8), so the waiting time for5 is26 -8 =18.
Waitingtimefor5=268=18Waiting\, time\, for\,5 =26 -8 =18

STEP 9

Now that we have the waiting times for all processes, we can calculate the average waiting time. The average waiting time is the total waiting time divided by the number of processes.
Averagewaitingtime=Totalwaitingtime/NumberofprocessesAverage\, waiting\, time = Total\, waiting\, time / Number\, of\, processes

STEP 10

Calculate the total waiting time by adding up the waiting times for all processes.
Totalwaitingtime=Waitingtimefor+Waitingtimefor2+Waitingtimefor3+Waitingtimefor4+Waitingtimefor5Total\, waiting\, time = Waiting\, time\, for\, + Waiting\, time\, for\,2 + Waiting\, time\, for\,3 + Waiting\, time\, for\,4 + Waiting\, time\, for\,5Totalwaitingtime=0+10+10+14+18=52Total\, waiting\, time =0 +10 +10 +14 +18 =52

STEP 11

Calculate the average waiting time by dividing the total waiting time by the number of processes.
Averagewaitingtime=Totalwaitingtime/Numberofprocesses=52/5=10.4Average\, waiting\, time = Total\, waiting\, time / Number\, of\, processes =52 /5 =10.4The average waiting time for these processes with the Shortest-Job-First scheduling algorithm is10.4 units of time.

Was this helpful?

Studdy solves anything!

banner

Start learning now

Download Studdy AI Tutor now. Learn with ease and get all help you need to be successful at school.

ParentsInfluencer programContactPolicyTerms
TwitterInstagramFacebookTikTokDiscord