Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by registered user 13bce0243 ( 9 years ago )
BANKERS ALGORITHM

#include<stdio>
int alloc[10][10];
int max[10][10];
int cneed[10][10];
int a[10];
int total[10];
void main()
{
int r,p,i,j,k,flag,f,count,x,flag1;
count=0;
flag1=0;
printf(“\nEnter number of resources:”);
scanf(“%d”,&r);
f=r;
printf(“\nEnter total memory of given resources sequentially:”);
for(i=0;i<r for(i=0;i for(j=0;j d=”,i); cneed[i][j]=max[i][j]-alloc[i][j]; k=0; for(j=0;j for(i=0;i a[k]+=alloc[i][j]; a[k]=total[k]-a[k]; while(count!=p) for(i=0;i flag=0; if(cneed[i][f]!=1) for(j=0;j total[j]=a[j]-cneed[i][j]; for(k=0;k flag=1; xss=removed cneed[i][f]!=1)) x=i; cneed[x][f]=1;>”,x);
count++;
for(i=0;i<r;i++)
{
total[i]+=max[x][i];
a[i]=total[i];
}
for(i=0;i<p;i++)
{
if((cneed[i][0]<a[

 

Revise this Paste

Children: 84135
Your Name: Code Language: