A single processor system has three resource types X, Y and Z, , which are…

2007

A single processor system has three resource types X, Y and Z, , which are shared by three processes. There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish LAST?

image.png

  1. A.

    P0

  2. B.

    P1

  3. C.

    P2

  4. D.

    None of the above, since the system is in a deadlock

Attempted by 21 students.

Show answer & explanation

Correct answer: C

First, calculate the total allocated resources: X = 1+2+2=5, Y = 2+0+2=4, Z = 1+1+1=3. Since there are 5 units of each resource type, the initial available resources are (5-5, 5-4, 5-3) = (0, 1, 2). Next, check which process request can be satisfied. P1 requests (0, 1, 2), which is less than or equal to Available (0, 1, 2). So P1 executes first. After P1 finishes, available resources become (0+2, 1+0, 2+1) = (2, 1, 3). Now check P0. P0 requests (1, 0, 3), which is less than or equal to Available (2, 1, 3). So P0 executes second. After P0 finishes, available resources become (2+1, 1+2, 3+1) = (3, 3, 4). Finally, P2 requests (1, 2, 0), which is less than or equal to Available (3, 3, 4). P2 executes last. The safe sequence is P1 -> P0 -> P2.

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

Explore the full course: Gate Guidance By Sanchit Sir