Consider a system with five processes P0 through P4 and three resource types…

2017

Consider a system with five processes P0 through P4 and three resource types A, B and C. Resource type A has seven instances, resource type B has four instances and resource type C has six instances. Suppose at time T0 we have the following allocation.

If we implement the Deadlock detection algorithm, we claim that the system is ________

Answer: D. Not in deadlock stateConcept: The deadlock detection algorithm works on the current resource-allocation state. Repeatedly look for any process whose remaining Request vector is…

  1. A.

    Semaphore

  2. B.

    Deadlock state

  3. C.

    Circular wait

  4. D.

    Not in deadlock state

Attempted by 176 students.

Show answer & explanation

Correct answer: D

Concept: The deadlock detection algorithm works on the current resource-allocation state. Repeatedly look for any process whose remaining Request vector is component-wise less than or equal to the current Available vector; let that process finish and add its Allocation back to Available. If every process can finish this way, the state is deadlock-free; if at some point no unfinished process can proceed, those remaining processes are deadlocked.

Setup: Available is (A=0, B=0, C=0). The resource totals are A=7, B=4, C=6 (each total equals the sum of that column's allocations plus the available amount). Now scan the processes to find one whose Request is satisfiable.

  1. P0: Request (0,0,0) <= Available (0,0,0). P0 finishes and releases its Allocation (0,1,0). Available becomes (0,1,0).

  2. P2: Request (0,0,0) <= Available (0,1,0). P2 finishes and releases (3,0,3). Available becomes (3,1,3).

  3. P3: Request (1,0,0) <= Available (3,1,3). P3 finishes and releases (2,1,1). Available becomes (5,2,4).

  4. P1: Request (2,0,2) <= Available (5,2,4). P1 finishes and releases (2,0,0). Available becomes (7,2,4).

  5. P4: Request (0,0,2) <= Available (7,2,4). P4 finishes and releases (0,2,2). Available becomes (7,4,6).

Cross-check: All five processes finished in the order P0, P2, P3, P1, P4 and Available returned to the resource totals (7,4,6). Because a complete finishing sequence exists, the system is not in a deadlock state. (Other valid orders also exist, e.g. P0, P2, P3, P4, P1.)

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

Explore the full course: Mppsc Assistant Professor Computer Science Paper 2

Loading lesson…