#include<iostream.h>
#include<stdio.h>
#include<fstream.h>
int main()
{ int n=3;
float total,wait[3]={0};
float p[3],twaiting=0,waiting=0;
int proc;
int stack[3];
float brust[3],arrival[3],sbrust,temp[3],top=3;
for(int j=0;j<n;j++)
{
p[j]=j;
stack[j]=j;
cout<<"enter arival time :";
cin>>arrival[j];
cout<<endl<<"enter brust time:";
cin>>brust[j];
temp[j]=arrival[j];
sbrust=brust[j]+sbrust;
}
int cont;
cout<<"enter contum time:";
cin>>cont;
int i=0;
while(1)
{ for(int m=0;m<cont;m++)
{
if(i==sbrust)
break;
proc=stack[0];
cout<<endl<<proc;
if(temp[proc]==i)
twaiting=0;
else
twaiting=i-(temp[proc]);
temp[proc]=i+1;
wait[proc]=wait[proc]+twaiting;
waiting=waiting+(twaiting);
brust[proc]=brust[proc]-1;
if(brust[proc]==0)
{
for(int x=0;x<top-1;x++)
stack[x]=stack[x+1];
top=top-1;
m=-1;
}
i=i+1;
}
if(i==sbrust)
break;
int tp=stack[0];
for(int x=0;x<top-1;x++)
stack[x]=stack[x+1];
stack[top-1]=tp;
m=-1;
}
cout<<"waiting:"<<waiting;
return 0;
}
Various Process Scheduling Algorithms:
#include<stdio.h>
#include<fstream.h>
int main()
{ int n=3;
float total,wait[3]={0};
float p[3],twaiting=0,waiting=0;
int proc;
int stack[3];
float brust[3],arrival[3],sbrust,temp[3],top=3;
for(int j=0;j<n;j++)
{
p[j]=j;
stack[j]=j;
cout<<"enter arival time :";
cin>>arrival[j];
cout<<endl<<"enter brust time:";
cin>>brust[j];
temp[j]=arrival[j];
sbrust=brust[j]+sbrust;
}
int cont;
cout<<"enter contum time:";
cin>>cont;
int i=0;
while(1)
{ for(int m=0;m<cont;m++)
{
if(i==sbrust)
break;
proc=stack[0];
cout<<endl<<proc;
if(temp[proc]==i)
twaiting=0;
else
twaiting=i-(temp[proc]);
temp[proc]=i+1;
wait[proc]=wait[proc]+twaiting;
waiting=waiting+(twaiting);
brust[proc]=brust[proc]-1;
if(brust[proc]==0)
{
for(int x=0;x<top-1;x++)
stack[x]=stack[x+1];
top=top-1;
m=-1;
}
i=i+1;
}
if(i==sbrust)
break;
int tp=stack[0];
for(int x=0;x<top-1;x++)
stack[x]=stack[x+1];
stack[top-1]=tp;
m=-1;
}
cout<<"waiting:"<<waiting;
return 0;
}
Various Process Scheduling Algorithms:
- First come First served Scheduling Algorithm
- Non preemptive Shortest job first (SJF) scheduling Algorithm
- preemptive shortest job first (SJF) scheduling algorithm
- Non preemptive priority scheduling algorithm
- preemptive priority scheduling algorithm
- Roun Robin scheduling Algorithm
Various Page Replacement Algorithms:
- Page replacement using Least Recently Used (LRU) algorithm techneques.
- Page replacement using First come first served algorithm techniques.
Various Disk Head Movement Counting Algorithms:
- Count the disk head movement using first come first served (FCFS) algorithm
- head movement count using shortest seek job first (SSJF)
- head movement count using scan scheduling algorithm
- head movement count using c-scan scheduling algorithm
- head movement count using loop scheduling algorithm
- head movement count using c-loop scheduling alogrithm
No comments:
Post a Comment