Project: Banker Algorithm
These are the instructions for your third programming project. Recall that all code must be written individually and independently. Violating this rule will result in zero credit for the project and probably a failing grade in the course.
Problem: In this project, you will write a Java/C++ program that implements the banker’s algorithm discussed in Section 8.6.3. Several customers request and release resources from the bank. The banker will grant a request only if it leaves the system in a safe state. A request is denied if it leaves the system in an unsafe state.
The bank will employ the strategy outlined in Section 8.6.3, whereby it will consider requests from n customers for m resources. The bank will keep track of the resources using the following data structures:
int numberOfCustomers; // the number of customers
int numberOfResources; // the number of customers
int [] available; // the available amount of each resource
int[][] maximum; // the maximum demand of each customer
int[][] allocation; // the amount currently allocated to each customer
int[][] need; // the remaining needs of each customer

The functionality of the bank appears in the interface shown in Figure 7.13 (Java). The implementation of this interface will require adding a constructor that is passed the number of resources initially available. For example, suppose we have three resource types with 10, 5, 7 resources initially available. In this case, we can create an implementation of the interface using the following code,
Bank bankExample = new BankImpl(10, 5, 7);

The bank will grant a request if the request satisfied the safety algorithm outlined in 8.6.3. If granting the request does leave the system in a safe state, the request is denied.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

// Program Name: <The name of your program file>
// Programmer: <Your name here>, <ID>
// Assignment Number: <put project number here, e.g. Project #3>
// Purpose: To implement banker's algorithm

//To test this code against exercise 8.9, you can change the content of "available" array on line 13
class Project3 {
    public static void main(String[] args) {
       int numberOfCustomers = 5;
       int numberOfResources = 4;
       boolean[] finish = new boolean[numberOfCustomers];
       int[] available = {1, 0, 0, 2};

       int[][] maximum = {
            {5, 1, 1, 7},...

By purchasing this solution you'll be able to access the following files: and Solution.pdf.

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Computer Science - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats