Answered step by step
Verified Expert Solution
Question
1 Approved Answer
use c++ or python Requirement Simulate the Banker's algorithm Suppose we have 3 resources, 5 processes For a given input of resource total number (Total
use c++ or python
Requirement Simulate the Banker's algorithm Suppose we have 3 resources, 5 processes For a given input of resource total number (Total vector) current resource allocation state (Allocation matrix) each maximization request (Max matrix) Determine whether deadlock will happen? If no deadlock, give a safe sequence of the processes. Implement in any programming language you prefer Refer to Chapter06 for details of the banker's algorithm General steps of the program You can read the inputs from either the command line or a (1) Let the user input the necessary data file Total vector: Total resource numbers Max matrix: Maximum required resources of each process Allocation matrix: Allocated resources to each process (2) Calculate the Need and Available data Need matrix: resources still need by each process Available vector: resources can be allocated (3) Determine whether the current state is safe or not If yes, print the safe sequence Sample input Total vector You can let the user input the total resources like below Total vector = [3 2 2] Please input the total resources of type 1: 3 Please input the total resources of type 2: 2 Please input the total resources of type 3: 2 Sample input - Max matrix Please input the Max resources of type 1 for process 1: 7 Please input the Max resources of type 2 for process 1: 5 Please input the Max resources of type 3 for process 1: 3 You can let the user input the maximum required resources shown in below table like this Max 7 5 3 3 2 2 9 0 2 2 2 2 4 3 3 Please input the Max resources of type 1 for process 2: 3 please input the Max resources of type 2 for process 2: 2 please input the Max resources of type 3 for process 2: 2 Please input the Max resources of type 1 for process 3: 9 please input the Max resources of type 2 for process 3: e Please input the Max resources of type 3 for process 3: 2 Please input the Max resources of type 1 for process 4: 2 Please input the Max resources of type 2 for process 4: 2 Please input the Max resources of type 3 for process 4: 2 Please input the Max resources of type 1 for process 5: 4 Please input the Max resources of type 2 for process 5: 3 lease put the Max resources of type 3 for process 3 The Allocation matrix is similar Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started