Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write an implementation of the Banker's Algorithm in PYTHON. If the input state is not a safe state, your algorithm should say this. If
Write an implementation of the Banker's Algorithm in PYTHON. If the input state is not a "safe state", your algorithm should say this. If it is a safe state, your algorithm should print a "safe sequence" of processes that we can execute, going from safe state to safe state, until all the processes have terminated. The input to your program should be the data we discussed in lectures - the matrices C, A, R and F. C and A are (n x m) while R and F are (1x m). Cij is the total amount of resource j that is needed by process i. Aij is the amount of resource j that is currently allocated to process i. Ri is the total amount of resource i in the system, while Fi is the amount of resource i that is free/available. You can assume all the numbers in C, A, R, F are non-negative integers. Please read in the data from the user: C and A can be read in as a "list of lists" while R and F are read in each as a list. Test your program, and report your result on the states defined by the following two sets of data: 1. R = [6,4,7,5], F = [3,1,1,1], C = [[3,3,2,2], [1,2,3,4],[1,3,5,0]], A = [[1,2,2,1],[1,0,3,3],[1,2,1,0]]. 2. R = [3,13,11], F = [1,5,2], C = [[0,0,1], [1,7,5], [2,3,5], [0,6,5]], A = [[0,0,1],[1,0,0],[1,3,5],[0,6,3]].
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