Operating Systems, Banker's algorithm.

K.I.L.E.R

Retarded moron
Veteran
This isn't a "do my homework" thread, as I don't have homework.

However I did decide to do some work on this algorithm.
I would like to ask you guys if my answers to the questions have been justified.

Existing resources use a vector variable 'E'.
Available resourcess use a vector variable 'A'.
Matrix 'C' is the current allocation of processes.
Matrix 'R' is the requests for the processes.

Processes are the row of the matrix, and columns are the resources themselves in a linear fashion; R1, R2, R3.

E = [6 3 6]
A = [1 2 0]

C =
[
3 0 1
1 1 3
0 0 2
1 0 0
]

R =
[
1 3 1
2 2 0
1 0 0
0 2 2
]

Question A:
Is the system safe or unsafe in respect to a deadlock? Show working.

P3: A = [1 2 0] + [0 0 2] = [1 2 2]
P4: A = [1 2 2] + [1 0 0] = [2 2 2]
P2: A = [2 2 2] + [1 1 3] = [3 3 5]
P1: A = [3 3 5] + [3 0 1] = [6 3 6]

The system is safe as the processes can all be completed successfully.

Question B:
Process 2 requests for a single allocation of Resource 2, should this be allocated to Process 2? Explain your answer.

Process 2 shouldn't be given a single resource of Resource 2 because Process 2 requires a total of 3 allocations of Resource 2.
Giving it a single resource when it wont complete the task is wasteful and undermines the entire point of the Banker's algorithm; to give resourcess to processess which will be guaranteed to complete and give back that processes resourcesses to guarantee other processes will run.

END

This was an exam question from the year 2001 final exam paper which was given to me by the lab instructor.

Do you guys believe my answer satisfies the questions asked?
 
Back
Top