Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the Banker's algorithm for deadlock avoidance, with a given set of N processes (NJava for the implementation, with a simple interface, where the user

Implement the Banker's algorithm for deadlock avoidance, with a given set of N processes (NJava for the implementation, with a simple interface, where the user only supplies the name of the input file (text file, say input.txt). The program reads all the necessary input data from that file. You are free to choose the format of the input file, just make sure it contains all the necessary data. The input data and the result of the algorithm must be displayed on the screen.

The pseudo code for the Greedy version for the Bankers algorithm can be found in this modules Commentary. We know that this algorithm only finds ONE solution (safe sequence of processes) assuming there is one; otherwise reports there is no solution.

You must adjust this algorithm to find exactly TWO solutions instead of just one (assuming of course there are at least two solutions). If the algorithm only has one solution this must be reported as such and the single solution must be displayed.

To resume, there are only three possible scenarios, for a correct input file:

1. There is no solution (no safe sequence). The program must report there is no solution. 2. There is EXACTLY ONE solution (safe sequence). The program must report there is exactly one

solution. The solution must be displayed on screen. 3. There are TWO OR MORE solutions (safe sequences). The program must find EXACTLY TWO

solutions. The solutions must be displayed on screen. If there are more than two solutions, it doesnt matter which ones are found, as long as they are exactly two.

Note 1: the solution must be based on the Greedy version for the Bankers algorithm; in particular, using an approach for finding ALL solutions and then keeping and reporting just two of them is NOT allowed.

Note 2: The input file may be incorrect, for various reasons. This must be checked and reported by your program before any attempt of finding a solution.

image text in transcribed

REFERENCE:

The following algorithm (in pseudo code) verifies if the system is in a safe state and if it is, computes the safe sequence of processes. If not, a corresponding message is displayed.

1. We need two additional vectors named Work (of length M) and Finish (of length N) in this algorithm. Initialize: Work[i] = Available[i], for i = 1, 2, , M Finish[i] = false, for i = 1, 2, , N Seq = empty list

2. Find an i, such that Finish[i] == false and Need[i][j]

3. Append process P[i] at the end of the safe sequence Seq. Work[j] = Work[j] +Allocation[i][j] for all j = 1, 2, , M Finish[i] = true Go to step 2 to check the status of resource availability for another process.

4. If Finish[i] == true for all values of i, this means that the system is safe, so print System is in a SAFE state and the safe sequence Seq. Otherwise, print System is in an UNSAFE state.

Implement the Banker's algorithm for deadlock avoidance, with a given set of N processes (N

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

5. Recognize your ability to repair and let go of painful conflict

Answered: 1 week ago