cs211 lab3
http://www.maths.nuigalway.ie/~gettrick/teach/cs211/labs/l3.html
-
For this lab you must submit all source code (python
files), and, if applicable, the result(s) of running the program on (a few)
test cases. This should be sent in as a file upload/attachment via BLACKBOARD (not directly by email).
The source code must
be well presented (indenting, spaces, reasonable variable/function names,
etc.) and must include comments (as a rough guideline - aim to have nearly as
many comments as lines of code). Any questions asked should be answered by
typing the answers into the relevant box on the BLACKBOARD upload form, or
by including the answer in comments in the PYTHON source code..
-
This material should be uploaded
before
the deadline of 10pm
Thursday October 26th., 2017. You will lose 20% for each day
(or part of day) the lab is late.
-
Plagiarism (the unattributed copying of work from other sources
(internet, fellow students,....)) will not be tolerated.
You risk getting zero for your lab if it is found to be
plagiarized.
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 (nxm) while R and F are (1xm).
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:
-
R = [6,5,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]].
-
R = [3,14,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]].
Submit your program and results via Blackboard.
©
NUI, Galway