Results 1 to 3 of 3
hi
Ive written these codes for cpu scheduling using roundrobin algorithm... would you plz help me for writing this in a thread....
and I think that it has some problem ...
- 02-02-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 1
simulates a CPU scheduling using Round Robin algorithm
hi
Ive written these codes for cpu scheduling using roundrobin algorithm... would you plz help me for writing this in a thread....
and I think that it has some problem that I dont understand....what shall I do?
int main()
{
int jobsource,Noofjobs,choice,qsize;
int pmin,pmax,pnum;
int amin,amax,anum;
int pairmin,pairmax,pairnum;
int burstmin,burstmax,burstnum;
int iomin,iomax,ionum;
char suppress;
cout<<"Choose job stream source:\n";
cout<<"From File press-1 or Random generation press-2:\t";
cin>>jobsource;
if ( jobsource==1)
{
}
else if(jobsource==2)
{
//job id will be A,B,C...
cout<<"Enter number of jobs:";
cin>>Noofjobs;
cout<<"\n";
cout<<"=========\n";
cout<<"Priority\n";
cout<<"=========\n";
cout<<"Min range:";
cin>>pmin;
cout<<"\n";
cout<<"Max range:";
cin>>pmax;
cout<<"\n";
for (int i = 0;i < Noofjobs; i++ )
{
pnum = (((double) rand() /
(double) RAND_MAX) * pmax + pmin);
}
cout<<"============\n";
cout<<"Arrival Time\n";
cout<<"============\n";
cout<<"Min range:";
cin>>amin;
cout<<"\n";
cout<<"Max range:";
cin>>amax;
cout<<"\n";
for (int i = 0;i < Noofjobs; i++ )
{
anum = (((double) rand() /
(double) RAND_MAX) * amax + amin);
}
cout<<"===========================\n";
cout<<"Numer of CPU/IO burst pairs\n";
cout<<"===========================\n";
cout<<"Min range:";
cin>>pairmin;
cout<<"\n";
cout<<"Max range:";
cin>>pairmax;
cout<<"\n";
for (int i = 0;i <1 ; i++ )
{
pairnum = (((double) rand() /
(double) RAND_MAX) * pairmax + pairmin);
}
cout<<"================\n";
cout<<"CPU burst size\n";
cout<<"=================\n";
cout<<"Min range:";
cin>>burstmin;
cout<<"\n";
cout<<"Max range:";
cin>>burstmax;
cout<<"\n";
for (int i = 0;i < pairnum ; i++ )
{
burstnum = (((double) rand() /
(double) RAND_MAX) * burstmax + burstmin);
}
cout<<"==============\n";
cout<<"IO burst size\n";
cout<<"================\n";
cout<<"Min range:";
cin>>iomin;
cout<<"\n";
cout<<"Max range:";
cin>>iomax;
cout<<"\n";
for (int i = 0;i < pairnum ; i++ )
{
ionum = (((double) rand() /
(double) RAND_MAX) * iomax + iomin);
}
}
cout<<"==================================\n";
cout<<"Choose CPU Scheduling Algorithm\n";
cout<<"==================================\n";
cout<<"1. FCFS \n";
cout<<"2. SHORTEST JOB FIRST (preemptive)\n";
cout<<"3. SHORTEST JOB FIRST (non-preemptive)\n";
cout<<"4. PRIORITY\n";
cout<<"5. ROUND ROBIN\n";
cout<<"Enter your choice(1-5):";
cin>>choice;
switch(choice) // Select a scheduling from the list
{
case 1: { fcfs();
break;
}
case 2: { sjfp();
break;
}
case 3: { sjfnp();
break;
}
case 4: { priority();
break;
}
case 5: { cout<<"Enter quantum size for RR";
cin>>qsize;
rr();
break;
}
}
cout<<"Suppress table output? Hit y to suppress,otherwise hit enter:";
cin>>suppress;
if(suppress='y')
{
cout<<"Trace Table";
//print out table
}
return 0;
}
- 02-02-2008 #2
When does your instructor say this assignment is due?
--
Bill
Old age and treachery will overcome youth and skill.
- 04-21-2008 #3Just Joined!
- Join Date
- Apr 2008
- Posts
- 1
CPU scheduling with Round Robin is not problem But the main problem occurs if?????..
Hello

can any1 help me in CPU SCHEDULING with ROUND ROBIN but the problem is that i have to do it with each process have perority with it.
like see format below:
Arrivel time CPU Burst PERORITY
5 9 4
7 3 2
8 3 5
9 11 1
take this example in to consideration solve problem if any1 can.
Nextly;
My schedsim must accept two command-line arguments: a) an input filename where a sequence of process arrival & burst times along with their priorities (integer between the range 1 – 5) is stored. The 2nd argument is: (b) the round-robin time quantum q (positive integer). Command line example:
>./schedsim schedtimes.dat 4
If schedsim is run with the wrong arguments or no arguments, it should print out a few lines summarizing the usage instructions and exit.
SOOOOOOOO plz help me.ill be thankfull to you guyzzzzzzz
Tke care


Reply With Quote