Any Ideas What's the best way to attack this? Can someone show me how this would work? Thanks
Suppose a system has 4 types of resources and 5 processes. Write a java program lab4.java to test whether the system is in a safe state. Lab4.java should define a system class and a main method. The system class contains the system snapshot, namely matrixes Allocated and Max, and vector Available. The system class also contains four methods: setAllocated(), setMax(), setAvailable(), safe().
Besides returning a Boolean value, the safe() function should print the result to indicate the system status: either "The system is not safe!" or "The system is safe, since the process sequence < P2, P3, P0, P1, P4 > satisfies the safety criteria." (The sequence is the one that makes Finish[i] true for every i from 0 to 4 in the safe() function.)
Write main() program to test whether the following system is safe:
____Allocation________Max________Available________ ___Need
____A B C D________ A B C D_______A B C D__________A B C D
_________________________________3 5 2 0
P0___3 0 0 2_________3 0 1 2
P1___1 0 0 0_________1 5 5 0
P2___1 3 5 4_________2 3 5 6
P3___0 6 3 2_________0 6 5 2
P4___0 0 1 4_________0 6 5 6
The main() program should contain the matrix assignment operations using the setAllocated(), setMax(), setAvailable() methods defined in the system class. Do not ask the user to input the values. |