bankers
DESCRIPTION
Bankers AlgorithmTRANSCRIPT
-
import java.util.Scanner;
public class Bankers{
private int need[][],allocate[][],max[][],avail[][],np,nr;
private void input(){
Scanner sc=new Scanner(System.in);
System.out.print("Enter no. of processes and resources : ");
np=sc.nextInt(); //no. of process
nr=sc.nextInt(); //no. of resources
need=new int[np][nr]; //initializing arrays
max=new int[np][nr];
allocate=new int[np][nr];
avail=new int[1][nr];
System.out.println("Enter allocation matrix -->");
for(int i=0;i
- for(int j=0;j
-
calc_need();
boolean done[]=new boolean[np];
int j=0;
while(j
-
}
/*
Enter no. of processes and resources : 3 4
Enter allocation matrix -->
1 2 2 1
1 0 3 3
1 2 1 0
Enter max matrix -->
3 3 2 2
1 1 3 4
1 3 5 0
Enter available matrix -->
3 1 1 2
Allocated process : 0
Allocated process : 1
Allocated process : 2
Safely allocated
*/