Sie sind auf Seite 1von 11

FCFS

program:

#include<stdio.h>

main()

{ int wt,p1,p2,p3,p4,w1=0,w2,w3,w4,n,t1,avg;

printf("enter the n value");

scanf("%d",&n);

printf("enter the values of p1,p2,p3,p4:");

scanf("%d%d%d%d",&p1,&p2,&p3,&p4);

w2=w1+p1;

w3=w2+p2;

w4=w3+p3;

wt=w4;

t1=(w1+p1)+(w2+p2)+(w3+p3)+(w4+p4);

avg=t1/n;

printf("turn around time is:%d \n",t1);

printf("average is %d",avg);

getch();

} output: enter the n value:4 enter the values of p1,p2,p3,p4: 38 6 6 5 turn around time is: 187 average is: 46.

MFT

Program :

#include<stdio.h> main() { int n,i,p[4],r,bs,np; printf("enter the buffer size"); scanf("%d",&n); if(n<=0) { printf("memory is not allocated"); exit(0); } printf("\nnumber of process:"); scanf("%d",&np); printf("\nenter the process size:"); for(i=1;i<=np;i++) scanf("%d",&p[i]); printf("\n enter the block size:"); scanf("%d",&bs); n=bs; printf("\n processn\t block size \t process time \t space"); for(i=1;i<=np;i++) { r=n-p[i]; printf("\n %d\t %d \t\t%d \t\t%d",i,n,p[i],r); } getch();

Output : enter the buffer size 100 number of process: 3 enter the process size:30 25 30 enter the block size:30 processn 1 2 3 block size 30 30 30 process time 30 25 20 space 0 5 10

MVT

Program: #include<stdio.h> main() { int mem,pro[10],n,i,total=0; printf("\nenter the memory size:"); scanf("%d",&mem); if(mem<=0) {

printf("\nthe memory is not required"); exit(0); } else { printf("\nenter the number of process:"); scanf("%d",&n); printf("\nenter the process time:"); for(i=1;i<=n;i++) { scanf("%d",&pro[i]); } for(i=1;i<=n;i++) total=total+pro[i]; printf("\nthe total memory is %d",total); if(mem==total) printf("\nthe memory is completely used"); else { if(mem>total) printf("\nthe remeaning memory is %d",mem-total); else printf("\n the required memory is %d",total-mem); } } getch();

} Output: enter the memory size:100 enter the number of process:3 enter the process time:30 25 30 the total memory is 85 the remeaning memory is 15

priaroty

Program: #include<stdio.h> #include<conio.h> main() { int p[10], w[10], b[10],i,j,n,temp,add,tat,sum; float avg; clrscr(); printf(enter the number of jobs:); scanf(%d,&n); printf(\n enter the burst time:); for(i=0; i<n; i++) scanf(%d,&b[i]); printf(enter the priority order :); for(i=0; i<n; i++)

scanf(%d,&p[i]); for(i=0; i<n; i++) { for(j=j+1; j<n; j++) { if(p[i]>p[j]) { temp=b[i]; b[i]=b[j]; b[j]=temp; } } } printf(\n priority order is:); for(i=0; i<n; i++) { printf(\t %d,b[i]); } w[0]=0; for(i=0; i<n; i++) { w[i+1]=w[i]+b[i]; printf(waiting time %d,w[i]); } sum=0; for(i=0; i<n; i++)

{ sum=sum+b[i]; } printf(\n sum of burst time %d,sum); add=0; for(i=0; i<n; i++) { add=add+w[i]; } printf(\n total turn around time); tat=add+sum; printf(%d,tat); printf(\n avg tat is %d,tat/n); getch(); }

output : enter number of jobs 3 enter the burst time: 5 6 2 enter the priority order: 1 2 4 priority order: 5 6 2

1 2 3

waiting time: 0 waiting time: 5 waiting time: 11

sum of burst times : 13 total turn around time: 29 avg tat: 9

round robin

Program: #include<stdio.h> void main() { int a[10],b[10],w[10],i,j,n; int t,sum=0; float avg; printf("enter the no.of jobs"); scanf("%d",&n); printf("enter the burst time"); for(i=0;i<n;i++); { scanf("%d",&b[i]); for(i=0;i<n;i++)

{ for(j=i+1;j<n;j++) { if(b[i]>b[j]) { t=b[i]; b[i]=b[j]; b[j]=t; } } }} w[0]=0; printf("waiting time"); for(i=0;i<n;i++) { w[i+1]=w[i]+b[i]; sum=sum+w[i]; printf("%d",w[i+1]); } printf("burst time is %d",w[i]); printf("total waiting time is %d",sum); printf("total turn around time is %d",w[i]+sum); avg=(sum+w[i])/n; printf("avg time is %d",avg); getch(); }

output:

enter number of jobs 4 enter the burst time: 38 6 6 5 38 6 6 5 after sorting 5 6 6 38 waiting time: 5111755 total burst time: 55 total waiting time: 33 turn around time: 88 average turn around time: 22.000000

Das könnte Ihnen auch gefallen