Computer Science Homework Solutions
Problem
#38850

Deadlocks

Specification
Implement the Banker's algorithm described in Section 8.5.3 using C/C++.  Your program should …

1) Prompt user to enter the size of matrix n and m.  Your program should accept any n x  m matrix and m vectors where n and m are positive integer less than 10.  
2) Read in Allocation, Max, and Available from allocation.txt, max.txt, and available.txt, respectively.  You can assume that each entry of the matrix (or vector) in the input files is separated with ' ' or 'n'.  That is, the input files

7 5 3 3 2 2 9 0 2 2 2 2

and

7 5 3
3 2 2
9 0 2
2 2 2

are considered to be identical entries, and they can be interpreted as 1x12, 2x6, 3x4, 4x3, and etc depending on the user input n and m.  Obviously, your program needs to handle the error when the total number of entries in matrix exceeding the total number of entries in input files.

3) Properly perform Safety algorithm to report user if the initial state is in safe state.   If state is safe, report a safe sequence and go to step 4.  If not, terminate the program.

4) Prompt user for new Requesti, perform Resource-Request algorithm, and perform Safety algorithm to report if the current state is safe.  If state is safe, report a safe sequence.  If state is unsafe, output "unsafe"

5) Repeat step 4 above until user terminates the program.

Solution
What is this?
By OTA - Overall OTA Rating
Farhan Chowdhury, MS - 4.4/5
Purchase Cost Now
$2.19 CAD (was ~$99.75)
Included in Download
  • Plain text response
  • Attached file(s):
    • banker.cpp
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Deadlock - A system has 5 active processes(A-E) and one type of resource, which there are 200 total unites available in the system. the current state of the system is shown in the table below. the HOLDS column ...
  • Requirements and Specifications - Describe in detail differences between a requirement and a specification. What do they have in common?
  • If interpreted code works slower than compiled code, then why do we use interpreters? - Interpreted code executes much more slowly than compiled code, yet several systems use them extensively. The most well known are Visual Basic (it has two modes: interpreter mode and compiler mode), Ja ...
  • Baselines - Assume that you're the manager of a small project. What baselines would you define for the project and how would you control them, also state what are baselines?
  • Multiple TCP connections and its effect on system performance - I cannot figure out how opening multiple simultaneous connections will affect the overall performance of the CPU or are you saying the processor will be stressed with such act that it will eventually ...
Browse