0% found this document useful (0 votes)
32 views2 pages

Bankers Algorithm CheatSheet

rgwe

Uploaded by

ashishtiwarypc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

Bankers Algorithm CheatSheet

rgwe

Uploaded by

ashishtiwarypc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Banker's Algorithm - Cheat Sheet

Banker's Algorithm (Safe Sequence Check)

4 Golden Steps (M-A-N-W-F-S):

1. M = Max Matrix

2. A = Allocation Matrix

3. N = Need = Max - Allocation

4. W = Work = Available (copy of available)

5. F = Finish = {false, false, ...} for each process

6. S = Safe Sequence (if possible)

Logic:

- For each process i, if Finish[i] == false and Need[i] <= Work:

-> Work += Allocation[i]

-> Finish[i] = true

-> Add i to Safe Sequence

Deadlock:

- If in one loop, no process can be executed (no allocation possible), then DEADLOCK.

Output:

- If all processes Finish = true -> Print Safe Sequence

- Else -> Deadlock Detected!

Tips to Remember:
- Always calculate Need matrix first!

- Use Work array to simulate available resources

- Think like a bank: only give if you can get back safely!

Variables:

- P: Number of processes

- R: Number of resource types

- avail[R]: Available instances of resources

- max[P][R]: Max demand of each process

- alloc[P][R]: Resources currently allocated

You might also like