We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Bankers algorithm (coursework)

jbessom
jbessom asked
on
Medium Priority
1,346 Views
Last Modified: 2013-11-23
1. The job is to fill out the BankImpl.java file with hints given in the code.
2.Once things start working, I can use the TestHarness program that is included.  To run it, type

Java TestHarness infile.txt 10 5 7

Or
Create a new project configuration from run ¿ set project configuration, and set arguments to be infile.txt 10 5 7.  

If you input * and press Enter, it will tell you the current state of your bank (as output by your getState() method). If you type
      RQ 0 2 2 2
then customer 0 will request two of each available resource.  Likewise,
      RL 0 2 2 2
will make customer 0 release two of each resource.

Here is an example output:
run:
*
Available
[10 5 7]

Allocation
[0 0 0]
[0 0 0]
[0 0 0]
[0 0 0]
[0 0 0]

Max
[7 5 3]
[3 2 2]
[9 0 2]
[2 2 2]
[4 3 3]

Need
[7 5 3]
[3 2 2]
[9 0 2]
[2 2 2]
[4 3 3]

RQ 4 2 3 5
*2*
*3*
*5*

 Customer # 4 requesting 2 3 5 Available = 10  5  7  Approved
*
Available
[8 2 2]

Allocation
[0 0 0]
[0 0 0]
[0 0 0]
[0 0 0]
[2 3 5]

Max
[7 5 3]
[3 2 2]
[9 0 2]
[2 2 2]
[4 3 3]

Need
[7 5 3]
[3 2 2]
[9 0 2]
[2 2 2]
[2 0 -2]

RL 4 2 2 2
*2*
*2*
*2*

 Customer # 4 releasing 2 2 2 Available = 10  4  4  Allocated = [0  1  3  ]*
Available
[10 4 4]

Allocation
[0 0 0]
[0 0 0]
[0 0 0]
[0 0 0]
[0 1 3]

Max
[7 5 3]
[3 2 2]
[9 0 2]
[2 2 2]
[4 3 3]

Need
[7 5 3]
[3 2 2]
[9 0 2]
[2 2 2]
[4 4 6]

RQ 0 1 0 2
*1*
*0*
*2*

 Customer # 0 requesting 1 0 2 Available = 10  4  4  Denied
*
Available
[10 4 4]

Allocation
[0 0 0]
[0 0 0]
[0 0 0]
[0 0 0]
[0 1 3]

Max
[7 5 3]
[3 2 2]
[9 0 2]
[2 2 2]
[4 3 3]

Need
[7 5 3]
[3 2 2]
[9 0 2]
[2 2 2]
[4 4 6]

src.project3.zip
Comment
Watch Question

Author

Commented:
More info:

The banker will only grant a request if it leaves the system in a safe state. It is denied if it is in an unsafe state

Please see attached jpg

Test the banker interface by using testharness.java file uploaded earlier. It expects the the interface to be called BankImp1 and requires an input file containing the maximum demand of each resource type for each customer. Example, if there are 5 customers and three resource types the input might be like:

7,5,3
3,2,2
9,0,2
2,2,2
4,3,3

The max demands for customer 0 is 7,5,3; customer 1 is 3,2,2, etc.

TestHarness.java requires the initial number number of resources available in the bank. Example, if there are initially 10, 5, and 7 resources, we invoke test harness as:

java TestHarness infile.txt 10 5 7
Bank.jpg
It looks like you want us to answer your schoolworks...

Hint : You have to consider using a "permanent" storage to account each customers their allocated ressources.
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Only partially correct
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.