#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;
cout<<"Enter your head:";
cin>>head;
int minindex;
int temp,len=0,i,j,rem[3],prev=ub,current=0,qsize=n,rsize=n;
for(i=0;i<n;i++)
{
cout<<"enter value for queue:";
cin>>queue[i];
rem[i]=i;
}
current=head;
for(i=0;i<n;i++)
{
prev=ub;
minindex=0;
for(j=0;j<rsize;j++)
{
temp=abs(current-queue[rem[j]]);
if(temp<prev)
{
minindex=j;
prev=temp;
}
}
len=len+prev;
cout<<endl<<len<<endl;
current=queue[rem[minindex]];
for(j=minindex;j<rsize-1;j++)
{
rem[j]=rem[j+1];
}
rsize=rsize-1;
}
cout<<endl<<"total ::";
cout<<len;
return 0;
}
Various Process Scheduling Algorithms:
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;
cout<<"Enter your head:";
cin>>head;
int minindex;
int temp,len=0,i,j,rem[3],prev=ub,current=0,qsize=n,rsize=n;
for(i=0;i<n;i++)
{
cout<<"enter value for queue:";
cin>>queue[i];
rem[i]=i;
}
current=head;
for(i=0;i<n;i++)
{
prev=ub;
minindex=0;
for(j=0;j<rsize;j++)
{
temp=abs(current-queue[rem[j]]);
if(temp<prev)
{
minindex=j;
prev=temp;
}
}
len=len+prev;
cout<<endl<<len<<endl;
current=queue[rem[minindex]];
for(j=minindex;j<rsize-1;j++)
{
rem[j]=rem[j+1];
}
rsize=rsize-1;
}
cout<<endl<<"total ::";
cout<<len;
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