Progs

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Progs as PDF for free.

More details

  • Words: 190
  • Pages: 7
PRORITY:#include<stdio.h> #include int f[40]; void main() { int n,i,j,k,l; int at[40],bt[40],ct[40],tat[40],wt[40],pro[40],pri[40]; int temp,prev,q[40]; clrscr();

printf("\nEnter no. of process:\n"); scanf("%d",&n); printf("\nEnter arrival times:\n"); for(i=1;i<=n;i++) { pro[i]=i; scanf("%d",&at[i]); } printf("\nEnter burst times:\n"); for(i=1;i<=n;i++) { f[i]=0; scanf("%d",&bt[i]); } printf("\nEnter priorities:\n"); for(i=1;i<=n;i++) scanf("%d",&pri[i]);

//sort for(i=1;i<=n;i++) { for(j=1;j
do { k=0; for(j=1;j<=n;j++) { if(f[pro[j]]==0 ) { if(at[j]<=prev) { q[k]=j; k++; } } } if(k==1) { ct[q[0]]=prev+bt[q[0]]; tat[q[0]]=ct[q[0]]-at[q[0]]; prev=ct[q[0]]; wt[q[0]]=tat[q[0]]-bt[q[0]];i++; f[pro[q[0]]]=1; } else if(k rel="nofollow">1) { for(j=0;j
{ if(pri[q[l+1]]>pri[q[l]]) { temp=q[l+1]; q[l+1]=q[l]; q[l]=temp; } else if(pri[q[l+1]]==pri[q[l]] && bt[q[l+1]]
} }while(i
printf("\n%d\t%d\t%d\t%d\t%d\t%d",pro[i],ct[i],at[i],bt[i],tat[i],wt[i]); getch(); } LRU:#include<stdio.h> Void main() { Int n1,n2,I,j,k=0,fault=0,l=1; Int pt[40],pa[40],count,flag; Printf(“Enter no. of pages:”); Scanf(“%d”,&n1); Printf(“Enter page table size:”); Scanf(“%d”,&n2); Printf(“Enter pages:”); For(i=1;i<=n1;i++) {scanf(“%d”,&pa[i]); For(i=1;i<=n2;i++) Pt[i]=0; Pt[l++]=pa[1];

For(i=2;i<=n1;i++) { Count=0;flag=0; For(j=1;j<=n2;j++) { If(pa[i]==pt[j]) {count=;break;} } If(l<=n2) { If(count==0) Pt[l++]=pa[i]; } Else { If(count==0) { K=pa[i-n2]; For(j=1;j<=n2;j++) { If(pt[j]==k) {pt[j]=pa[i];fault++;} } } } } Printf(“%d”,fault); }

Related Documents

Progs
November 2019 5
Progs
November 2019 7
Progs
November 2019 8
Bailout Progs
April 2020 23