Suppose there are four processes in execution with 12 instances of a Resource…

2016

Suppose there are four processes in execution with 12 instances of a Resource R in a system.

The maximum need of each process and current allocation are given below :

With reference to current allocation, is system safe ? If so, what is the safe sequence ?

  1. A.

    No

  2. B.

    Yes, P1P2P3P4

  3. C.

    Yes, P4P3P1P2

  4. D.

    Yes, P2P1P3P4

Attempted by 121 students.

Show answer & explanation

Correct answer: C

Step 1: Compute available resources. Total R = 12, allocated = 3 + 4 + 2 + 1 = 10, so available = 2.

Step 2: Compute remaining need for each process.

  • P1: need = 8 − 3 = 5

  • P2: need = 9 − 4 = 5

  • P3: need = 5 − 2 = 3

  • P4: need = 3 − 1 = 2

Step 3: Find a safe sequence using the Banker's algorithm.

  1. Available = 2. P4's need = 2 ≤ available, so run P4 and release its allocation 1 → new available = 3.

  2. Available = 3. P3's need = 3 ≤ available, so run P3 and release its allocation 2 → new available = 5.

  3. Available = 5. P1's need = 5 ≤ available, so run P1 and release its allocation 3 → new available = 8.

  4. Available = 8. P2's need = 5 ≤ available, so run P2 and release its allocation 4 → new available = 12.

Conclusion: The system is safe. One safe sequence is P4 → P3 → P1 → P2.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor