





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Operating system practical file .
Typology: Slides
1 / 29
This page cannot be seen from the preview
Don't miss anything!






















#include
cout<<"average turn around time:
n"<<avg_around_tm<<endl<<"average waiting time:
n"<<avg_wait_tm<<endl; return 0; }
#include
cout<<"Gantt Chart\n "; for(time=0;time<total;) { for(i=0;i<n;i++) { if(at[i]<=time && finish[i]==0) { cout<<"("<<time<<")|==P"<<(i+1)<<"==|"; if(rt[i]<q) { dec=rt[i]; } else {dec=q;} rt[i]=rt[i]-dec; if(rt[i]==0) finish[i]=1; for(j=0;j<n;j++) if(j!=i && finish[j]==0 && at[j]<=time) wt[j]+=dec; time=time+dec; } } } //ducslectures.blogspot.in cout<<"("<<total<<")"<<endl; dispTime(); } int main() { sched s; int ch; s.computeRR();
if(f[k].arv_tm==0) { flag=0; break; } k++; } if(!flag) { cout<<"enter all values of arival time as no arrival time is 0\n"; return 1; } for(k=0;k<n;k++) { temp=f[k]; for(int i=k+1;i<n;i++) { if(temp.burst_tm>f[i].burst_tm) { temp=f[i]; f[i]=f[k]; f[k]=temp; } } } cout<<"Entered info is as follows:\n"; float avg_wait_tm=0,avg_around_tm=0; for(k=0;k<n;k++) { f[k].wait_tm=sum-f[k].arv_tm; if(f[k].wait_tm<0) f[k].wait_tm=0; if(f[k].arv_tm>(f[k-1].burst_tm+f[k-
1].arv_tm)) { carry=f[k].arv_tm-sum; sum+=(f[k].burst_tm+carry); } else sum+=f[k].burst_tm; avg_wait_tm+=f[k].wait_tm; avg_around_tm+=f[k].wait_tm+f[k].burst_tm; } avg_around_tm/=n; avg_wait_tm/=n; for(k=0;k<n;k++) { cout<<"pid: "<<f[k].pid<<endl<<"Burst time: "<<f[k].burst_tm<<endl<<"arrival time: "<<f[k].arv_tm<<endl<<"Waiting time:
sjf *f=new sjf[n]; for( int i=0;i<n;i++) { cout<<"Enter the process id:\n"; cin>>f[i].pid; cout<<"Enter the burst timing:\n"; cin>>f[i].burst_tm; cout<<"Enter the arrival timing:\n"; cin>>f[i].arv_tm; } int k1=0,flag=1; while(k1<n) { if(f[k1].arv_tm==0) { flag=0; break; } k1++; } if(flag==1) { cout<<"enter all values of arival time as no arrival time is 0\n"; return 1; } for(int k=0;k<n;k++) { temp=f[k]; for(int i=k+1;i<n;i++) { if(temp.arv_tm>f[i].arv_tm) { temp=f[i]; f[i]=f[k]; f[k]=temp; } //cout<<"f[0]: "<<f[0].pid<<endl; } }
for(int k=0;k<n;k++) { cout<<"pid: "<<f[k].pid<<endl<<"Burst time: "<<f[k].burst_tm<<endl<<"arrival time: "<<f[k].arv_tm<<endl<<"Waiting time: "<<f[k].wait_tm<<endl; } cout<<"Entered info is as follows:\n"; carry=f[0].arv_tm; int i=0; for(int k=1;k<n;k++) { if(f[k].arv_tm==carry) { if(f[i].burst_tm>f[k].burst_tm) i=k; } else { cout<<"carry break\n"; break; } } int j,tem=0,k,b; do { j=0; if((f[i].arv_tm<=sum)&&(f[i].temp!=1)) { f[i].wait_tm=sum-f[i].arv_tm; f[i].temp=1; sum+=f[i].burst_tm; } else { if(tem==0) { sum=f[i].arv_tm; tem=1;