Mukesh Kumar OS Lab File
Mukesh Kumar OS Lab File
Mukesh Kumar OS Lab File
FCFS SCHEDULING
Step 3: For each process in the ready Q, assign the process id and accept the CPU burst time
Step 4: Set the waiting of the first process as ‘0’ and its burst time as its turn around time
a) Waiting time for process(n)= waiting time of process (n-1) + Burst time ofprocess(n-1)
b) Turn around time for Process(n)= waiting time of Process(n)+ Burst time forprocess(n)
Step 6: Calculate
#include<stdio.h>
void main()
int i,n,sum,wt,tat,twt,ttat;
int t[10];
float awt,atat;
clrscr();
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("\n %d",&t[i]);
sum=0;
twt=0;
ttat=t[0];
for(i=1;i<n;i++)
sum+=t[i-1];
wt=sum;
tat=sum+t[i];
twt=twt+wt;
ttat=ttat+tat;
printf("\n\n");
}
awt=(float)twt/n;
atat=(float)ttat/n;
getch();
OUTPUT:
1 0 2
2 2 7
3 7 11
Average Waiting Time 3.00
SJF SCHEDULING
Step 3: For each process in the ready Q, assign the process id and accept the CPU burst time
Step 4: Start the Ready Q according the shortest Burst time by sorting according to lowest to
Step 5: Set the waiting time of the first process as ‘0’ and its turnaround time as its burst time.
(a) Waiting time for process(n)= waiting time of process (n-1) + Burst time ofprocess(n-1)
(b) Turn around time for Process(n)= waiting time of Process(n)+ Burst time forprocess(n)
Step 6: Calculate
#include<stdio.h>
void main()
int i,j,k,n,sum,wt[10],tt[10],twt,ttat;
int t[10],p[10];
float awt,atat;
clrscr();
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("\n %d",&t[i]);
for(i=0;i<n;i++)
p[i]=i;
for(i=0;i<n;i++)
{
for(k=i+1;k<n;k++)
if(t[i]>t[k])
int temp;
temp=t[i];
t[i]=t[k];
t[k]=temp;
temp=p[i];
p[i]=p[k];
p[k]=temp;
wt[0]=0;
for(i=0;i<n;i++)
sum=0;
for(k=0;k<i;k++)
wt[i]=sum+t[k];
sum=wt[i];
}
}
for(i=0;i<n;i++)
tt[i]=t[i]+wt[i];
for(i=0;i<n;i++)
twt=0;
ttat=t[0];
for(i=1;i<n;i++)
twt=twt+wt[i];
ttat=ttat+tt[i];
awt=(float)twt/n;
atat=(float)ttat/n;
getch();
OUTPUT:
1 3 0 3
0 4 3 7
2 5 7 12
PRIORITY SCHEDULING
Step 3: For each process in the ready Q, assign the process id and accept the CPU burst time
Step 5: Set the waiting of the first process as ‘0’ and its burst time as its turn around time
(a) Waiting time for process(n)= waiting time of process (n-1) + Burst time ofprocess(n-1)
(b) Turn around time for Process(n)= waiting time of Process(n)+ Burst time forprocess(n)
Step 7: Calculate
#include <stdio.h>
#include <conio.h>
void main()
int i,j,n,tat[10],wt[10],bt[10],pid[10],pr[10],t,twt=0,ttat=0;
float awt,atat;
clrscr();
scanf("%d", &n);
for (i=0;i<n;i++)
pid[i] = i;
scanf("%d",&bt[i]);
scanf ("%d",&pr[i]);
// Sorting start
for (i=0;i<n;i++)
for(j=i+1;j<n;j++)
t = pr[i];
pr[i] = pr[j];
pr[j] =t;
t = bt[i];
bt[i] = bt[j];
bt[j] =t;
t = pid[i];
pid[i] = pid[j];
pid[j] = t;
// Sortingfinished
tat[0] = bt[0];
wt[0] =0;
for (i=1;i<n;i++)
{
printf("\n \n");
printf("\n \n");
for(i=0;i<n;i++)
printf("\n%d\t\t%d\t%d\t\t%d\t\t%d",pid[i],pr[i],bt[i],wt[i],tat[i]);
for(i=0;i<n;i++)
ttat = ttat+tat[i];
awt = (float)twt / n;
atat = (float)ttat / n;
getch();
OUTPUT:
-----------PRIORITY SCHEDULING--------------
2 1 4 0 4
1 2 6 4 10
0 3 2 10 12
3 7 5 12 17
Algorithm for RR
Step 1: Start the process
Step 2: Accept the number of processes in the ready Queue and time quantum (or) time slice
Step 3: For each process in the ready Q, assign the process id and accept the CPU burst time
Step 4: Calculate the no. of time slices for each process where
Step 5: If the burst time is less than the time slice then the no. of time slices =1.
(a) Waiting time for process(n) = waiting time of process(n-1)+ burst time of process(n-1 ) +
the time difference in getting the CPU fromprocess(n-1)
(b) Turn around time for process(n) = waiting time of process(n) + burst time of process(n)+
the time difference in getting CPU fromprocess(n).
Step 7: Calculate
#include<stdio.h>
#include<conio.h>
int z[10],b[10],n,m[50],r,q,e=0,avg=0,i,j;
floatf;
main()
clrscr();
printf("\n\tJOB SCHEDULING ALGORITHM[RR]");
printf("\n\t*******************************************************\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&b[i]); z[i]=b[i];
scanf("%d",&q);
rr();
average();
getch();
return 0;
rr()
int max=0;
max=b[1];
for(j=1;j<=n;j++)
if(max<=b[j])
max=b[j];
if((max%q)==0)
r=(max/q);
else
r=(max/q)+1;
for(i=1;i<=r;i++)
printf("\nround %d",i);
for(j=1;j<=n;j++)
if(b[j]>0)
b[j]=b[j]-q;
if(b[j]<=0)
b[j]=0;
printf("\nprocess %d is completed",j);
else
delay(1000);
return 0;
average()
for(i=1;i<=n;i++)
e=0;
for(j=1;j<=r;j++)
if(z[i]!=0)
if(z[i]>=q)
{
m[i+e]=q; z[i]-=q;
else
m[i+e]=z[i]; z[i]=0;
else
m[i+e]=0;
e=e+n;
for(i=2;i<=n;i++)
for(j=1;j<=i-1;j++)
avg=avg+m[j];
for(i=n+1;i<=r*n;i++)
if(m[i]!=0)
for(j=i-(n-1);j<=i-1;j++)
avg=m[j]+avg;
f=avg/n;
printf("\nTOTAL WATING:%d",avg);
printf("\n\nAVERAGE WAITING TIME:%f\n",f);
for(i=1;i<=r*n;i++)
{ if(m[i]!=0)
if(i%n==0){
printf("P%d",(i%n)+(n)); }
else
printf("P%d",(i%n));
for(j=1;j<=m[i];j++)
printf("%c",22);
printf("\n");
getch();
return 0;
OUTPUT
*******************************************************
Process 1:10
Process 2:15
Process 3:20
Process 4:25
round 1
round 2
process 1 is completed
round 3
process 2 is completed
round 4
process 3 is completed
round 5
process 4 is completed
TOTAL WATING:130
P1▬▬▬▬▬P2▬▬▬▬▬P3▬▬▬▬▬P4▬▬▬▬▬P1▬▬▬▬▬P2▬▬▬▬▬P3▬▬▬▬▬P4
▬▬▬▬▬P2▬▬▬▬▬P3▬▬▬▬▬P4▬▬▬▬▬P3▬
▬▬▬▬P4▬▬▬▬▬P4▬▬▬▬▬
Experiment No.5
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
main()
int n,i,j,b[20],sb[20],t[20],x,c[20][20];
clrscr();
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
scanf("%d",&sb[i]);
t[i]=sb[i];
for(j=0;j<b[i];j++)
c[i][j]=sb[i]++;
printf("Filename\tStart block\tlength\n");
for(i=0;i<n;i++)
printf("%d\t %d \t%d\n",i+1,t[i],b[i]);
scanf("%d",&x);
printf("length is:%d",b[x-1]);
printf("Partitions occupied:");
for(i=0;i<b[x-1];i++)
printf("%4d",c[x-1][i]);
getch();
OUTPUT:
1 2 4
2 5 10
ALGORITHM:
Step 5: Get all different Partitions allocated of different files one by one
PROGRAM:
#include<stdio.h>
#include<conio.h>
main()
int n,m[20],i,j,sb[20],s[20],b[20][20],x;
clrscr();
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d%d",&sb[i],&s[i]);
scanf("%d",&m[i]);
printf("enter Partitions of file%d:",i+1);
for(j=0;j<m[i];j++)
scanf("%d",&b[i][j]);
} printf("\nFile\t index\tlength\n");
for(i=0;i<n;i++)
printf("%d\t%d\t%d\n",i+1,sb[i],m[i]);
scanf("%d",&x);
i=x-1;
printf("Index is:%d",sb[i]);
for(j=0;j<m[i];j++)
printf("%3d",b[i][j]);
getch();
OUTPUT:
254672647
1 2 10
2 3 5
ALGORITHM:
Step 5: Get Starting block and all different Partitions allocated of different files one by one
PROGRAM:
#include<stdio.h>
#include<conio.h>
struct file
char fname[10];
int start,size,block[10];
}f[10];
main()
inti,j,n;
clrscr();
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s",&f[i].fname);
printf("Enter starting block:");
scanf("%d",&f[i].start);
f[i].block[0]=f[i].start;
scanf("%d",&f[i].size);
for(j=1;j<=f[i].size;j++)
scanf("%d",&f[i].block[j]);
printf("File\tstart\tsize\tblock\n");
for(i=0;i<n;i++)
printf("%s\t%d\t%d\t",f[i].fname,f[i].start,f[i].size);
for(j=1;j<=f[i].size-1;j++)
printf("%d--->",f[i].block[j]);
printf("%d",f[i].block[j]);
printf("\n");
getch();
OUTPUT:
12
15
45
32
25
venkat20 6 4--->12--->15--->45--->32--->25
rajesh12 5 6--->5--->4--->3--->2
Experiment No.8
Algorithm:
Program:-
#include<stdio.h>
#include<conio.h>
main()
int i,m,n,tot,s[20];
clrscr();
scanf("%d",&tot);
printf("Enter no. of pages:");
scanf("%d",&n);
scanf("%d",&m);
for(i=0;i<n;i++)
{
scanf("%d",&s[i]);
}
tot=tot-m;
for(i=0;i<n;i++)
if(tot>=s[i])
else
getch();
OUTPUT:
Enterno.ofpages 4
Enter memoryforOS 10
Enter sizeofpage 10
Enter sizeofpage 9
Enter sizeofpage 10
External Fragmentation is = 2
Experiment No.9
PROGRAM:
#include<stdio.h>
#include<conio.h>
main()
int ms,i,ps[20],n,size,p[20],s,intr=0;
clrscr();
scanf("%d",&ms);
ms-=s;
size=ms/n;
for(i=0;i<n;i++)
{
if(ps[i]<=size)
intr=intr+size-ps[i];
printf("process%d is allocated\n",p[i]);
else
printf("process%d is blocked",p[i]);
getch();
OUTPUT:
Internal Fragmentation is = 4
Experiment No.10
BANKER’S ALGORITHM
Banker’s Algorithm:
When a new process enters a system, it must declare the maximum number of instances of each
resource type it needed. This number may exceed the total number of resources in the system. When
the user request a set of resources, the system must determine whether the allocation of each
resources will leave the system in safe state. If it will the resources are allocation; otherwise the
process must wait until some other process release the resources.
3. work=work+Allocation, Finish[i]=True;
4. if Finish[1]=True for all I, then the system is in safestate.
Let Request i be request vector for the process Pi, If request i=[j]=k, then process Pi wants k
instances of resource type Rj.
Allocation I =Allocation+Request I;
If the resulting resource allocation state is safe, the transaction is completed and process Pi is
allocated its resources. However if the state is unsafe, the Pi must wait for Request i and the old
resource-allocation state is restored.
ALGORITHM:
1. Start theprogram.
2. Get the values of resources andprocesses.
3. Get the availvalue.
4. After allocation find the needvalue.
5. Check whether its possible toallocate.
6. If it is possible then the system is in safestate.
7. Else system is not in safetystate.
8. If the new request comes then check that the system is insafety.
9. or not if we allow therequest.
10. stop theprogram.
#include<stdio.h>
char res[10]={'A','B','C','D','E','F','G','H','I','J'};
void main()
int i,j,ch,n,m,work1[5];
int avble[5],alloc[5][5],max[5][5],need[5][5];
scanf("%d",&n);
scanf("%d",&m);
for(i=0;i<m;i++)
{
printf("\n\tRESOURCE %c:\t",res[i]);
scanf("%d",&avble[i] );
for(i=0;i<n;i++)
for(j=0;j<m;j++)
printf("\n\tRESOURCE %c : \t",res[j]);
scanf("%d",&max[i][j]);
printf(" A PROCESS.\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
printf("\n\tRESOURCE %c : \t",res[j]);
scanf("%d",&alloc[i][j]);
for(i=0;i<m;i++)
work1[i]=0;
for(j=0;j<n;j++)
work1[i]+=alloc[j][i];
avble[i]=avble[i] -work1[i];
for(i=0;i<n;i++)
for(j=0;j<m;j++)
need[i][j]=max[i][j]-alloc[i][j];
while(1)
scanf("%d",&ch);
switch(ch)
case1:
disp(m,n,alloc,max,avble,need);
break;
case2:
safesq(m,n,alloc,avble,need);
break;
case3:
resreq(m,n,alloc,avble,need);
break;
case4:
exit(0);
default:
int i,j;
printf("\n\t\tALLOCATION\tMAX\tNEED\t AVAILABLE");
printf("\t\t");
for(i=0;i<4;i++)
for(j=0;j<m;j++)
printf("%c ",res[j]);
printf(" ");
for(i=0;i<n;i++)
printf("\n\tP%d\t",i);
for(j=0;j<m;j++)
printf("%d ",alloc[i][j]);
printf(" ");
for(j=0;j<m;j++)
printf("%d ",max[i][j]);
printf("\t");
for(j=0;j<m;j++)
printf("%d ",need[i][j]);
printf(" ");
if(i==0)
for(j=0;j<m;j++)
printf("%d ",avble[j]);
int i,j,k=0,l,work[5],work1[5],fin[5],flag=0,flag1=0,safesq[6];
for(i=0;i<m;i++)
work[i]=avble[i];
for(i=0;i<n;i++)
fin[i]=0;
for(l=0;l<n;l++)
for(i=0;i<n;i++)
flag1=0;
if(fin[i]==0)
flag1=1;
break;
if(flag1==0)
for(j=0;j<m;j++)
work[j]=work[j]+alloc[i][j];
fin[i]=1;
safesq[k]=i;
k++;
for(i=0;i<n;i++)
if(fin[i]==0)
flag=1;
break;
}
if(flag==0)
for(i=0;i<n;i++)
printf("P%d ",safesq[i]);
int i,j,num,alloc1[5][5],avble1[5],req[5],flag=0,flag1=0;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
alloc1[i][j] = alloc[i][j];
for(j=0;j<m;j++)
avble1[j]=avble[j];
scanf("%d",&num);
printf("\n\tRESOURCE %c:\t",res[i]);
scanf("%d",&req[i]);
for(i=0;i<m;i++)
if(req[i]>need[num][i])
flag=1;
break;
if(flag==0)
for(i=0;i<m;i++)
flag1=1;
break;
if(flag1==0)
for(i=0;i<m;i++)
avble1[i]=avble1[i]-req[i];
alloc1[num][i]=alloc1[num][i]+req[i];
need[num][i]=need[num][i]-req[i];
safesq(m,n,alloc1,avble1,need);
else
{
else
OUTPUT:
//TEST CASE 1:
PROCESS1
PROCESS2
PROCESS3
MAXIMUM VALUE FOR RESOURCE 1:3
MAXIMUM VALUE FOR RESOURCE 2:1
PROCESS 4
P2 010 623
P1 401 723
P3 620 934
P4 514 936
//TEST CASE:2
ENTER THE NO. OF PROCESSES:4
PROCESS1
PROCESS2
PROCESS3
PROCESS4
DEADLOCK OCCURED
Experiment No.11
ALGORITHM:
Step 2: When the page is required replace the page at the head of the queue
Step 3: Now the new page is inserted at the tail of the queue
#include<stdio.h>
#include<conio.h>
int fr[3];
void main()
void display();
int i,j,page[12]={2,3,2,1,5,2,4,5,3,2,5,2};
int flag1=0,flag2=0,pf=0,frsize=3,top=0;
clrscr();
for(i=0;i<3;i++)
fr[i]=-1;
for(j=0;j<12;j++)
flag1=0;
flag2=0;
for(i=0;i<12;i++)
if(fr[i]==page[j])
{
flag1=1;
flag2=1;
break;
if(flag1==0)
for(i=0;i<frsize;i++)
if(fr[i]==-1)
fr[i]=page[j];
flag2=1;
break;
if(flag2==0)
fr[top]=page[j];
top++;
pf++;
if(top>=frsize)
top=0;
display();
getch();
void display()
int i;
printf("\n");
for(i=0;i<3;i++)
printf("%d\t",fr[i]);
OUTPUT:
564123
Reference np4-> 5 6 4 -1
Reference np1-> 5 6 4 1
Reference np2-> 2 6 4 1
Reference np3-> 2 3 4 1
No.ofpagesfaults .... 6
Experiment No.12
Here we select the page that has not been used for the longest period of time.
ALGORITHM:
Step 2: When the page is required replace the page at the head of the queue
Step 3: Now the new page is inserted at the tail of the queue
Step 5: When the page fault occurs replace page present at the bottom of the stack
Program:-
#include<stdio.h>
#include<conio.h>
int fr[3];
void main()
void display();
int p[12]={2,3,2,1,5,2,4,5,3,2,5,2},i,j,fs[3];
int index,k,l,flag1=0,flag2=0,pf=0,frsize=3;
clrscr();
for(i=0;i<3;i++)
fr[i]=-1;
for(j=0;j<12;j++)
{
flag1=0,flag2=0;
for(i=0;i<3;i++)
if(fr[i]==p[j])
flag1=1;
flag2=1;
break;
}
if(flag1==0)
for(i=0;i<3;i++)
if(fr[i]==-1)
fr[i]=p[j];
flag2=1;
break;
if(flag2==0)
for(i=0;i<3;i++)
fs[i]=0;
for(k=j-1,l=1;l<=frsize-1;l++,k--)
for(i=0;i<3;i++)
if(fr[i]==p[k])
fs[i]=1;
}
for(i=0;i<3;i++)
if(fs[i]==0)
index=i;
fr[index]=p[j];
pf++;
display();
getch();
void display()
int i;
printf("\n");
for(i=0;i<3;i++)
printf("\t%d",fr[i]);
OUTPUT:
Reference NO 6->6 -1 -1
Reference NO 5-> 6 5 -1
Reference NO 4-> 6 5 4
Reference NO 2-> 2 5 4
Reference NO 3-> 2 3 4
Reference NO 1-> 2 3 1
No.of page faults...6
Experiment No.13
ALGORITHM:
Optimal algorithm
Here we select the page that will not be used for the longest period of time.
OPTIMAL:
Step 2: When the page fault occurs replace page that will not be used for the longest
period of time.
Program:-
#include<stdio.h>
#include<conio.h>
int i,j,nof,nor,flag=0,ref[50],frm[50],pf=0,victim=-1;
int recent[10],optcal[50],count=0;
int optvictim();
void main()
clrscr();
printf("\n............................... ");
scanf("%d",&nof);
scanf("%d",&nor);
scanf("%d",&ref[i]);
clrscr();
printf("\n.............................. ");
printf("\n................... \n");
for(i=0;i<nor;i++)
printf("%4d",ref[i]);
for(i=0;i<nof;i++)
frm[i]=-1;
optcal[i]=0;
for(i=0;i<10;i++)
recent[i]=0;
printf("\n");
for(i=0;i<nor;i++)
flag=0;
printf("\n\tref no %d ->\t",ref[i]);
for(j=0;j<nof;j++)
if(frm[j]==ref[i])
flag=1;
break;
if(flag==0)
count++;
if(count<=nof)
victim++;
else
victim=optvictim(i);
pf++;
frm[victim]=ref[i];
for(j=0;j<nof;j++)
printf("%4d",frm[j]);
getch();
int i,j,temp,notfound;
for(i=0;i<nof;i++)
notfound=1;
for(j=index;j<nor;j++)
if(frm[i]==ref[j])
notfound=0;
optcal[i]=j;
break;
if(notfound==1)
return i;
temp=optcal[0];
for(i=1;i<nof;i++)
if(temp<optcal[i])
temp=optcal[i];
for(i=0;i<nof;i++)
if(frm[temp]==frm[i])
return i;
return 0;
OUTPUT:
Reference NO 6->6 -1 -1
Reference NO 5-> 6 5 -1
Reference NO 4-> 6 5 4
Reference NO 2-> 2 5 4
Reference NO 3-> 2 3 4
Reference NO 1-> 2 3 1
PAGING
Algorithm:
Program:-
#include <stdio.h>
#include <conio.h>
struct pstruct
int fno;
int pbit;
}ptable[10];
int pmsize,lmsize,psize,frame,page,ftable[20],frameno;
void info()
scanf("%d",&pmsize);
scanf("%d",&lmsize);
void assign()
int i;
for (i=0;i<page;i++)
ptable[i].fno =-1;
ptable[i].pbit=-1;
for(i=0; i<frame;i++)
ftable[i] = 32555;
for (i=0;i<page;i++)
scanf("%d",&frameno);
ftable[frameno] = i;
if(ptable[i].pbit == -1)
ptable[i].fno = frameno;
ptable[i].pbit = 1;
getch();
// clrscr();
printf("\n\nPAGE TABLE\n\n");
for (i=0;i<page;i++)
printf("%d\t\t%d\t\t%d\n",i,ptable[i].fno,ptable[i].pbit);
printf("\n\n\n\tFRAME TABLE\n\n");
printf("FrameAddress PageNo\n\n");
for(i=0;i<frame;i++)
printf("%d\t\t%d\n",i,ftable[i]);
voidcphyaddr()
intladdr,paddr,disp,phyaddr,baddr;
getch();
// clrscr();
scanf("%d",&baddr);
scanf("%d",&laddr);
if(ptable[paddr].pbit == 1)
void main()
clrscr();
info();
assign();
cphyaddr();
getch();
OUTPUT:
PAGE TABLE
0 5 1
1 6 1
2 7 1
3 2 1
FRAME TABLE
FrameAddress PageNo
0 32555
1 32555
2 3
3 32555
4 32555
5 0
6 1
7 2
SEGMENTATION
AIM:
ALGORITHM:
Step 3: get the base address and length for each segment.
Step 5: check whether the segment number is within the limit, if not display the error
message.
Step 6: Check whether the byte reference is within the limit, if not display the error
message.
#include <stdio.h>
#include <conio.h>
#include <math.h>
int sost;
void gstinfo();
voidptladdr();
structsegtab
int sno;
int baddr;
int limit;
int val[10];
}st[10];
void gstinfo()
int i,j;
scanf("%d",&sost);
for(i=1;i<=sost;i++)
st[i].sno = i;
scanf("%d",&st[i].baddr);
scanf("%d",&st[i].limit);
for(j=0;j<st[i].limit;j++)
scanf("%d",&st[i].val[j]);
void ptladdr()
int i,swd,d=0,n,s,disp,paddr;
clrscr();
for(i=1;i<=sost;i++)
printf("\t\t%d \t\t%d\t\t%d\n\n",st[i].sno,st[i].baddr,st[i].limit);
printf("\n\nEnter the logical Address:");
scanf("%d",&swd);
n=swd;
while (n !=0)
n=n/10;
d++;
s = swd/pow(10,d-1);
disp = swd%(int)pow(10,d-1);
if(s<=sost)
else
else
void main()
char ch;
clrscr();
gstinfo();
do
{
ptladdr();
flushall();
scanf("%c",&ch);
getch();
OUTPUT:
SEGMENT TABLE
1 4 5
2 5 4
3 3 4
SEGMENT TABLE
1 4 5
2 5 4
3 3 4
Do U want to Continue(Y/N)
Experiment No.16
#include<stdio.h>
#include<process.h>
void main()
int partition[20],process[20],i,j,n,m;
printf("Enter no of Partitions.\n");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d", &Partition[i]);
printf("Enter no of Process.\n");
scanf("%d",&m);
for(i=0;i<m;i++)
scanf("%d", &process[i]);
for(i=0;i<n;i++)
for(j=0;j<m;j++)
if(process[j]<=Partition[i])
process[j]=10000;
break;
}}}
for(j=0;j<m;j++)
if(process[j]!=10000)
getch();}
Output:
Enter no of Partitions.
Enter no of Process.