bankersalgorithm
bankersalgorithm
h>
#include<conio.h>
int main()
count = 0;
scanf("%d", &p);
scanf("%d", &r);
printf("\n\nEnter the Max Matrix for each process : "); //for loop statement to
enter the maximum matrix.
scanf("%d", &Max[i][j]);
printf("\n\nEnter the allocation for each process : "); //for loop statement to
enter the allocation of resources for each process.
{
printf("\nFor process %d : ",i + 1);
scanf("%d", &alloc[i][j]);
printf("\n\nEnter the Available Resources : "); //for loop for entering the
no of available resources.
scanf("%d", &avail[i]);
do
printf("\t\t");
printf("\n");
process = -1;
for(i = 0; i<p; i++)
process = i ;
if(avail[j]<need[i][j])
process = -1;
break;
if(process != -1)
break;
if(process != -1)
safeSequence[count] = process + 1;
count++;
avail[j] += alloc[process][j];
alloc[process][j] = 0;
Max[process][j] = 0;
completed[process] = 1;
}
}while(count != p && process != -1);
if(count == p)
printf(" \n");
else
return 0;