# Andrew S. Tanenbaum (OS) Edition 4 Exercise 6 Question 25 (Page No. 467)

72 views
The banker’s algorithm is being run in a system with $m$ resource classes and $n$ processes. In the limit of large $m$ and $n,$ the number of operations that must be performed to check a state for safety is proportional to $m^{a} n^{b}.$ What are the values of $a$ and $b?$

Each process has an array(size = m) of resources allocated to it.

Ex: $$P_i = [r_1, r_2, r_3, ...., r_m]$$

To check for a safe state:

In first loop, we may find a process that can be executed with the available resources and this takes O(mn).

In second loop, we have (n-1) processes and time complexity is O((n-1)m).

...

...

In last loop, we need to check for that single process whether it can be executed or not, time complexity = O(m)

So, total time complexity = $$O(m(n+(n-1)+(n-2)+.....+1)) = O(m^1n^2)$$

a = 1, b = 2

## Related questions

1
40 views
One way to eliminate circular wait is to have rule saying that a process is entitled only to a single resource at any moment. Give an example to show that this restriction is unacceptable in many cases.
Suppose that process $A$ in Fig. 6-12 requests the last tape drive. Does this action lead to a deadlock?
Consider the previous problem again, but now with $p$ processes each needing a maximum of $m$ resources and a total of $r$ resources available. What condition must hold to make the system deadlock free?