Question: Aim : Simulate Bankers algorithm for Deadlock Avoidance using C + + or Bash. THEORY: Banker's algorithm is a deadlock avoidance algorithm. It is named
Aim :
Simulate Bankers algorithm for Deadlock Avoidance using C or Bash.
THEORY:
Banker's algorithm is a deadlock avoidance algorithm. It is named so because this algorithm
is used in banking systems to determine whether a loan can be granted or not.
Consider there are n account holders in a bank and the sum of the money in all their
accounts is S Every time a loan has to be granted by the bank, it subtracts the loan
amount from the total money the bank has. Then it checks if that difference is greater than S
It is done because, only then, the bank would have enough money even if all the n account
holders draw all their money at once.
Banker's algorithm works in a similar way in operating systems. Whenever a new process is
created, it must specify the maximum instances of each resource type that it needs, exactly.
Assume that there are n processes and m resource types in the system.
ALGORITHM:
Start the program.
Get the values of resources and processes.
Get the available value.
After allocation find the need value.
Check whether its possible to allocate.
If it is possible then the system is in the safe state.
Else system is not in the safety state.
If the new request comes then check that the system is in safe state.
If so grant the request.
If not, deny the request.
Stop the program.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
