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

Operating System Concept Note: Write the code in C with enough comments Use the

ID: 3744479 • Letter: O

Question

Operating System Concept

Note: Write the code in C with enough comments

Use the side scroll bar to see the complete table. Please do not copy previous Chegg code. Thank you

Use a computer to view and scroll horizontal to view the complete table

Uniprocessor Scheduling

Write a program to simulate FCFS, RR (q=1), SPN, and  SRT. Run at 1,000 simulations. Each simulation needs to include 20 processes which require a randomly determined amount of execution time in the range of [1,10]. The each job becomes available at the time of twice its index (i.e., job 0 is available at time 0, job 17 is available at time 34).

Draw a conclusion as to which of these scheduling algorithms are best under these circumstances

Process 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Arrival Time 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 Service Time 1 9 5 8 2 10 4 8 9 10 3 9 2 10 6 7 6 9 5 3 FCFS Finish Time 1 10 15 23 25 35 39 47 56 66 69 78 80 90 96 103 109 118 123 126 Turnaround Time 1 9 13 20 21 30 33 40 48 57 59 67 68 77 82 88 93 101 105 107 55.95 Relative Turnaround Time 1 1 2.6 2.5 10.5 3 8.25 5 5.333333 5.7 19.66667 7.444444 34 7.7 13.66667 12.57143 15.5 11.22222 21 35.66667 11.16607 Process 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Arrival Time 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 Service Time 7 7 3 9 1 3 10 7 6 7 5 5 3 3 6 2 4 10 3 4 FCFS Finish Time 7 8 11 20 21 24 34 41 47 54 59 64 67 70 76 78 82 92 95 99 Turnaround Time 7 7 9 17 17 19 28 34 39 45 49 53 55 57 62 63 66 75 77 80 42.95 Relative Turnaround Time 1 1 3 1.888889 17 6.333333 2.8 4.857143 6.5 6.428571 9.8 10.6 18.33333 19 10.33333 31.5 16.5 7.5 25.66667 20 11.00206 Process 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Arrival Time 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 Service Time 2 5 8 3 8 8 9 5 1 6 6 6 1 8 5 6 3 10 5 10 FCFS Finish Time 2 6 14 17 25 33 42 47 48 54 60 66 67 75 80 86 89 99 104 114 Turnaround Time 2 5 12 14 21 28 36 40 40 45 50 55 55 62 66 71 73 82 86 95 46.9 Relative Turnaround Time 1 1 1.5 4.666667 2.625 3.5 4 8 40 7.5 8.333333 9.166667 55 7.75 13.2 11.83333 24.33333 8.2 17.2 9.5 11.91542 Process 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Arrival Time 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 Service Time 7 2 1 1 3 8 10 8 7 2 6 8 8 6 2 9 7 5 2 5 FCFS Finish Time 7 3 4 5 8 16 26 34 41 43 49 57 65 71 73 82 89 94 96 101 Turnaround Time 7 2 2 2 4 11 20 27 33 34 39 46 53 58 59 67 73 77 78 82 38.7 Relative Turnaround Time 1 1 2 2 1.333333 1.375 2 3.375 4.714286 17 6.5 5.75 6.625 9.666667 29.5 7.444444 10.42857 15.4 39 16.4 9.125615 Report Turnaround Time 46.125 Relative Turnaround Time 10.80229

Explanation / Answer

#include<stdio.h>

int main()
{
int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;
printf("Enter total number of processes(maximum 20):");
scanf("%d",&n);

printf(" Enter Process Burst Time ");
for(i=0;i<n;i++)
{
printf("P[%d]:",i+1);
scanf("%d",&bt[i]);
}

wt[0]=0; //waiting time for first process is 0

//calculating waiting time
for(i=1;i<n;i++)
{
wt[i]=0;
for(j=0;j<i;j++)
wt[i]+=bt[j];
}

printf(" Process Burst Time Waiting Time Turnaround Time");

//calculating turnaround time
for(i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i];
avwt+=wt[i];
avtat+=tat[i];
printf(" P[%d] %d %d %d",i+1,bt[i],wt[i],tat[i]);
}

avwt/=i;
avtat/=i;
printf(" Average Waiting Time:%d",avwt);
printf(" Average Turnaround Time:%d",avtat);

return 0;
}