Banker algorith
Banker algorith
Ban
ker's
Alg
orith
m
#inc
lude
<std
io.h
>
int
mai
n()
{
//P0,P1,P2,P3,P4 are the Process names here
int avail[3]={3,3,2};//Available
Resources
intflag =0;
for(j= 0;j< m;j++) {
if(need[i][j]>avail[j]){
f
l
a
g
=
1
;
b
r
e
a
k
;
}
}
if(flag ==0){
ans[ind++]=i;
for(y =0;y <m;y++)
avail[y]+= alloc[i][y];
f[i]= 1;
}
}
}
}