Lab. No 9 Virtual Round Robin Best Operating System
Lab. No 9
Virtual Round Robin
Virtual- Time Round-Robin (VTRR), a proportional share scheduler that can provide good proportional sharing accuracy with O(1) scheduling overhead. VTRR achieves this by combining the benefits of fair queuing algorithms with a round-robin scheduling mechanism. Unlike many other schedulers, VTRR is simple to implement. VTRR provides accurate proportional share allocation with constant, sub-microsecond scheduling overhead. The scheduling overhead using VTRR is two orders of magnitude less than the standard Linux scheduler for large numbers of clients.
Direction: Virtual Round Robinin C++.
#include
int main()
{
intcount,j,n,time,remain,flag=0,time_quantum;
intwait_time=0,turnaround_time=0,at[10],bt[10],rt[10];
printf("Enter Total Process:\t ");
scanf("%d",&n);
remain=n;
for(count=0;count0)
{
time+=rt[count];
rt[count]=0; flag=1;
}
else if(rt[count]>0)
{
rt[count]-=time_quantum;
time+=time_quantum; }
if(rt[count]==0 && flag==1)
{
remain--;
printf("P[%d]\t|\t%d\t|\t%d\n",count+1,time-at[count],time-at[count]-bt[count]);
wait_time+=time-at[count]-bt[count];
turnaround_time+=time-at[count];
flag=0;
}
if(count==n-1)
count=0;
else if(at[count+1]<=time)
count++;
else
count=0;
}
printf("\nAverage Waiting Time= %f\n",wait_time*1.0/n);
printf("Avg Turnaround Time = %f",turnaround_time*1.0/n);
return 0;
}
Output:
Comments: ___________________________.
Date: ______________________. Signature of Lab Instructor: _____________________.
Comments
Post a Comment