I've been looking for the last 3 hours, and I'm not getting a problem with this code. The number of user processes and the number of types of resources and algorithm determines whether there is any deadlock or not. I am convinced that this problem is in the stepTwo () method as I have seen everything in the first section of the code, and this It was all right.
Here's the pseudagon:
Here are the main, variables, etc.:
public class assignment III {public static entity operation; // represents the number of processes, people have static int number resources; // represents the number of different types of resources, public static int [] is available; // Make matrix for available procedures public stable int [] [] Allocation; // Make Allotment Matrix Public Static Ent [] [] Request; // Request matrix create public stable int [] work; // Work Matrix Public Stable Boolean [] Finish; // Finish Matrix Public Stable Zero Create (string [] args) FileNotFoundException throws {try {scanner scan = new scanner (System.in); Scanner fileScan = new scanner (new file ("input3.txt")); // Create a file scanner System.out.println ("Enter the total number of processes:"); NumProcesses = scan.nextInt (); System.out.println ("Please enter the number of different types of resources:"); NumResources = scan.nextInt (); // Provide matrices size = new [numResources]; Allocation = new difference [numProcesses] [numResources]; Request = new difference [numProcesses] [numResources]; Work = new difference [number processing]; Finish = new boolean [numprocesses]; Start the matrix content available for // (Int i = 0; i & lt; numResources; i ++) [i] = fileScan.nextInt (); // For the allocation, start the matrix content (int j = 0; j & lt; numprocesses; j ++) for (int k = 0; k
The error is happening from somewhere, but I can not understand it:
public static zero phase (two) (// step 2 : Find an index J where the finish [j] = false & request [j] & lt; = for the task (int j = 0; j and lt; numprrocesses; j ++) {if (end [j] = = True & amp; amp; amp; amp; === numprocesses) {System.out.println ("no deadlock");} for (int i = 0; i work [i] & end [j] = = Incorrect) {System.out.println ("P" + J + "Deadlock.");}}}}}
My input is:
0 0 0
0 1 0
2 0 0
3 0 3
2 1 1
0 0 2
0 0 0
2 0 2
0 0 0
1 0 0
0 2 2
The output I get is:
P1 Deadlock is P1 Deadlock.
The correct output should be "no deadlock".
Any help would be appreciated.
No comments:
Post a Comment