Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Operating Systems (CSE) implementing Bankers algorithm Bankers Algorithm: [ CODE MUST BE IN JAVA PROGRAMMIMG LANGUAGE] The Banker's algorithm is run by the operating system

Operating Systems (CSE)

implementing Bankers algorithm

Bankers Algorithm: [ CODE MUST BE IN JAVA PROGRAMMIMG LANGUAGE]

The Banker's algorithm is run by the operating system whenever a process requests resources.

The algorithm avoids deadlock by denying or postponing the request if it determines that accepting the request could put the system in an unsafe state (one where deadlock could occur).

When a new process enters a system, it must declare the maximum number of instances of each resource type that it may ever claim; clearly, that number may not exceed the total number of resources in the system. Also, when a process gets all its requested resources it must return them in a finite amount of time.

image text in transcribed

Algorithm for checking to see if a state is safe:

1. Look for row, R, whose unmet resource needs all A. If no such row exists, system will eventually deadlock since no process can run to completion

2. Assume process of row chosen requests all resources it needs and finishes. Mark process as terminated, add all its resources to the A vector.

3. Repeat steps 1 and 2 until either all processes marked terminated (initial state was safe) or no process left whose resource needs can be met (there is a deadlock).

image text in transcribed

image text in transcribed

CD ROMS Tape drives Plotters Process Printers CD ROMS Tape drives Plotters Process Printers 0 E = (6342) P = (5322) A = (1020) A3 0 1 1 B0100 01110 D 1 1 0 1 E0000 Resources assigned A1 1 0 B| 01/12 C3100 D0010 E 2110 Resources still needed IN PUT: // take input from file 4 // no. of processes 5 // no. of resources 11213 // Max. resource Matrix 22 210 21310 11221 10211 // Resource allocation Matrix 20110 11010 11110 00212 // resource available OUTPUT: Need Matrix : 01002 02100 10300 00111 Safe sequence is : DACB Change in available resource matrix : 113 2 2 21533 3 2 5 43 5 2 6 53

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

More Books

Students also viewed these Databases questions

Question

When should managers investigate variances?

Answered: 1 week ago

Question

=+16.1. 13.91 Suppose that (12) Answered: 1 week ago

Answered: 1 week ago