Question: Write a program (in java) that detects if there is a deadlock in the system by using a resource allocation graph. Your program should read

Write a program (in java) that detects if there is a deadlock in the system by using a resource allocation graph. Your program should read from a file the following inputs: the number of processes and the number of resources. For each process it should read four numbers: the number of resources it is currently holding, the IDs of resources it is holding, the number of resources it is currently requesting, the IDs of resources it is requesting. The output of the program should indicate if there is a deadlock in the system. In case there is, the program should print out the identities of all processes that are deadlocked. (For simplicity, consider there is only one instance of each resource.) A sample input:

2 2 //number of processes, number of resources

1 1 1 2 // 4 numbers for process 1

1 2 1 1 // 4 numbers for process 2

Output: Deadlock

***NOTE: Please clarify the steps and don't copy the answer from different questions exist here in Chegg because they are differen from this Q!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!