Implementing Bankers Algorithm in C++

Here is C++ implementation of Bankers Algorithm.

#include
#include
void main()
{
int avres[4]={3,1,1,2};
int alres[4][4]={ {1,2,2,1},{1,1,3,3},{1,1,1,0},{3,2,1,1}};
int mres[4][4]={ {3,3,2,2},{1,7,3,4},{1,1,5,0},{2,2,3,3}};
int i,j,r;
int flagVar=0;
for(i=0;i<3;i++) { for(j=0;j<3;j++) { if( mres[i][j]-alres[i][j]>avres[j])
{
flagVar=1;
r=i;
break;
}
}
}
if(r==0)
{
cout<<"\n The state is in safe mode and no deadlock happened"; } else { cout<<"\n The process no "<

Leave a Reply

Your email address will not be published. Required fields are marked *