Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a program that can examine the Bankers algorithm to check a request. When the system allocates the resource according to the request and

Please write a program that can examine the Bankers algorithm to check a request. When the system allocates the resource according to the request and the system is in a safe state, the request will be accepted. Otherwise, the request should be block.

Rules:

1.The init.txt contains the resource allocation information. The format of init.txt is as following: First line: n m //n is the amount of process, and m is the amount of resource type. Second line to n+1 line are the allocation matrix (n x m), and allocation[i,j] = k means that Pi is currently allocated k instances of Rj. n+2 to 2n+2 line are the maximal matrix (n x m), and maximal[i,j] = k means that request at most k instances of resource type Rj. 2n+3 line is the available vector of length m. If available [j] = k, means that there are k instances of resource type Rj.

2.The cmd.txt is the request vector of length m+2. cmd[0] is command type (0: finish 1:request 2:release). cmd[1] is the process ID. cmd[2] to cmd[m+2] denote the request[0] to request[m]. requesti [j] = k means that process Pi wants k instances of resource type Rj.

3.According to the Bankers algorithm in the textbook, write a program to determine whether the request should be accepted or block.

4.Display the decision is Accept or Block. Program Structure: 1.You should implement your programs using C or C++. 2.The copy file name is mybanker. Requirement: Your C/C++ programs should be compiled by gnu C/C++, and can be running on UNIX/Linux based machine. If your programs cannot be complied by gnu C/C++ compiler, or cannot not be running on UNIX/Linux based virtual machine and real machine will be treat as garbage.

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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

Design a job advertisement.

Answered: 1 week ago