Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to write a banker's algorithm program that reads text file and gives output txt file? This assignment uses java This assignment involves Banker's Alogrithm.

How to write a banker's algorithm program that reads text file and gives output txt file? This assignment uses java This assignment involves Banker's Alogrithm. The program must be named "banker" and will read the allocation, max, available, and request vectors from a file. The name of the file will be passed to your program as a command line argument.

The input file format is the following:

- number of processes: n -

number of resource types: m -

An n x m allocation matrix -

An n x m max matrix -

A 1 x m available vector -

A i : 1 x m request vector

Program will output the following in a standardized format.

- Echo the number of processes.

- Echo the number of resource types.

- Echo the allocation matrix. Label the processes and resource types (see sample output).

- Echo the max matrix. Label the processes and resource types (see sample output).

- Compute and print the need matrix. Label the processes and resource types (see sample output).

- Echo the available vector. Label the resource types.

- Compute if the system is in a safe state.

- Echo the request vector. Label the process making the request and resource types (see sample output).

- Compute if the request can be granted.

- Compute the new available vector (see sample output).

SAMPLE INPUT FILE ------------------------------------------------------

5

4

0 0 1 2

1 0 0 0

1 3 5 4

0 6 3 2

0 0 1 4

0 0 1 2

1 7 5 0

2 3 5 6

0 6 5 2

0 6 5 6

1 5 2 0

1:0 4 2 0

---------------------------------------------------------------------- SAMPLE OUTPUT FILE ------------------------------------------------------------- There are 5 processes in the system.

There are 4 resource types.

The Allocation Matrix is...

A B C D

0: 0 0 1 2

1: 1 0 0 0

2: 1 3 5 4

3: 0 6 3 2

4: 0 0 1 4

The Max Matrix is...

A B C D

0: 0 0 1 2

1: 1 7 5 0

2: 2 3 5 6

3: 0 6 5 2

4: 0 6 5 6

The Need Matrix is...

A B C D

0: 0 0 0 0

1: 0 7 5 0

2: 1 0 0 2

3: 0 0 2 0

4: 0 6 4 2

The Available Vector is...

A B C D

1 5 2 0

THE SYSTEM IS IN A SAFE STATE!

The Request Vector is...

A B C D

1:0 4 2 0

THE REQUEST CAN BE GRANTED!

The Available Vector is...

A B C D

1 1 0 0

------------------------------------------------------- This is how the program should be run:

% banker s1.txt

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_2

Step: 3

blur-text-image_3

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

How can training contribute to a sustainability initiative?

Answered: 1 week ago