New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



Resources » Articles/Knowledge Sharing » General »

Round robin scheduling program in c


Posted Date: 07 Nov 2009    Resource Type: Articles/Knowledge Sharing    Category: General
Author: karthickMember Level: Silver    
Rating: 3 out of 53 out of 53 out of 5Points: 2




#include
main()
{
int i,wa=0,cumx[30],b[30],count=0,wait[30],k,x[30],xx[30];
int a,t=0,e,c,n,b1[30],max=0,wt=0,s,j;
system("clear");
printf("\n \t Round Robin Scheduling:");
printf("\n Enter the number of jobs:");
scanf("%d",&n);
for(i=0;i<20;i++)
{
xx[i]=-1;
wait[i]=0;
}
for(i=0;i {
printf("\n Enter the bursttime for job %d:",i+1);
scanf("%d",&b[i]);
b1[i]=b[i];
max=max>b[i]?max:b[i];
}
printf("\n Enter the timeslice for jobs:");
scanf("%d",&s);
k=1;
for(j=0;j {
printf("\n \t Job \t Exectime \t Remainingtime");
for(i=0;i {
if(b[i]==0)
continue;
if(b[i] {
a=b[i];
x[k]=i;
xx[k]=b[i];
k++;
}
else
{
a=s;
x[k]=i;
xx[k]=s;
k++;
}
b[i]-=a;
printf("\n \t %d \t\t %d \t\t %d",i+1,a,b[i]);
}
printf("\n\n");
}
for(i=1;i<=k;i++)
count+=1;
cumx[1]=0;
for(i=2;i<=count;i++)
{
cumx[i]=xx[i-1]+cumx[i-1];
printf("%d ",cumx[i]);
}
for(j=0;j for(i=count-1;i>=1;i--)
if(x[i]==j)
{
wait[j]=cumx[i+1]-b1[j];
t=t+cumx[i+1];
break;
}
printf("\n Waiting Time \n");
for(i=0;i {
printf("%d\n",wait[i]);
wa+=wait[i];
}
printf("\n Average Waiting time is ,%f",(float)wa/n);
printf("\n Average Executuion time is ,%f",(float)t/n);
wt=wa+t;
printf("\n Average turnaround time is ,%f",(float)wt/n);
}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
SOURCE CODE  .  SCHEDULING  .  ROUND ROBIN  .  PROGRAM  .  CODING  .  C LANGUAGE  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Priority scheduling program in c
Previous Resource: Sjf scheduling program in c
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
More Resources



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.