Safety Algorithm
Q1. Explain Safety Algorithm.
Ans. Following are the steps taken in Safety Algorithm:
Step 1:
Let work and finish the vectors of length ‘m’ and ‘n’ respectively.
Initialize work=available and
If finish [i]=false
where
for i=0 to n-1
Step 2:
Find an i such that both
a) finish[i]=false
b) needi ≤ work[or available]
If no such exist, go to step 4.
Step 3:
Work = Work + Allocation
finish[i]=true
Go to step 2.
Step 4:
If finish[i]=true for all i, then the system in a safe state.