šŸŽ“ BookMCQ
← Back to 7. Deadlocks

šŸ“ Multiple Instance Deadlock Detection (48 MCQs)

šŸ“– From Operating System • 7. Deadlocks • 48 questions available

What is Multiple Instance Deadlock Detection?

Definition:
Detection for multiple-instance resources uses an algorithm similar to Banker's safety check, identifying processes that cannot possibly finish given current availability.

Example:
Initialize Work=AvailableWork = Available; repeatedly find unfinished PiP_i with Requesti≤WorkRequest_i \leq Work; remaining unfinished processes constitute deadlock set DD.

Reason:
This adaptation of the safety algorithm correctly identifies deadlocks in complex multi-resource environments where simple cycle detection is insufficient.

13
Easy
21
Medium
14
Hard

šŸ“ All Multiple Instance Deadlock Detection MCQs

Q1. Why is the Wait-For Graph scheme not applicable to systems with multiple resource instances?

A.It is too slow.
B.A cycle in the graph does not necessarily imply deadlock. āœ…
C.It requires too much memory.
D.It only works for single processes.
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: In multiple-instance systems, a process might wait for a resource held by another, but if there are other free instances or if other processes release instances, the wait can be resolved without the holder releasing. Thus, a cycle is not sufficient to prove deadlock.

Q2. Which data structure indicates the number of available instances of each resource type?

A.Allocation
B.Request
C.Available āœ…
D.Max
šŸ’” Difficulty: easy | āœ… Correct: C

šŸ“– Explanation: The `Available` vector, of length m, tracks the number of free instances for each resource type currently in the system.

Q3. What does the `Request` matrix represent in this detection algorithm?

A.The maximum demand of each process.
B.The remaining need of each process.
C.The current resource request of each process. āœ…
D.The total resources in the system.
šŸ’” Difficulty: easy | āœ… Correct: C

šŸ“– Explanation: Unlike the Banker's Algorithm which uses `Need` (Max - Allocation), this detection algorithm uses `Request`, which specifies the resources a process is *currently* asking for at the time of detection.

Q4. How is the `Work` vector initialized in the detection algorithm?

A.To zero.
B.To the `Available` vector. āœ…
C.To the `Max` vector.
D.To the `Allocation` vector.
šŸ’” Difficulty: easy | āœ… Correct: B

šŸ“– Explanation: The algorithm starts by setting `Work` equal to `Available`. `Work` simulates the pool of resources that can be used to satisfy pending requests during the detection process.

Q5. If a process Pi has `Allocation_i` equal to zero, how is `Finish[i]` initialized?

A.false
B.true āœ…
C.Null
D.Undefined
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: If a process holds no resources (`Allocation_i == 0`), it cannot be holding up other processes in a circular wait. Therefore, it is marked as `Finish[i] = true` initially, assuming it is not part of a deadlock.

Q6. If a process Pi has `Allocation_i` not equal to zero, how is `Finish[i]` initialized?

A.true
B.false āœ…
C.Zero
D.One
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: Processes holding resources are potential participants in a deadlock. They are initialized to `Finish[i] = false` and must be proven able to complete during the algorithm's execution.

Q7. What condition must be met to select a process Pi in Step 2 of the algorithm?

A.Finish[i] == true and Request_i ≤ Work
B.Finish[i] == false and Request_i > Work
C.Finish[i] == false and Request_i ≤ Work āœ…
D.Finish[i] == true and Request_i ≄ Work
šŸ’” Difficulty: hard | āœ… Correct: C

šŸ“– Explanation: The algorithm looks for a process that has not yet been marked as finished (`Finish[i] == false`) and whose current request can be satisfied by the available simulated resources (`Request_i ≤ Work`).

Q8. When a process Pi is selected in Step 2, how is `Work` updated in Step 3?

A.Work = Work - Request_i
B.Work = Work + Allocation_i āœ…
C.Work = Work + Request_i
D.Work = Work - Allocation_i
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: Once Pi is deemed able to complete (its request is met), the algorithm assumes it will finish and release all its currently held resources. Thus, `Allocation_i` is added to `Work`.

Q9. What happens to `Finish[i]` when process Pi is processed in Step 3?

A.It remains false.
B.It is set to true. āœ…
C.It is deleted.
D.It is set to null.
šŸ’” Difficulty: easy | āœ… Correct: B

šŸ“– Explanation: Marking `Finish[i] = true` indicates that process Pi can successfully complete its task in the simulated sequence, releasing its resources.

Q10. After the algorithm completes, how is a deadlocked process identified?

A.Finish[i] == true
B.Finish[i] == false āœ…
C.Request_i == 0
D.Allocation_i == 0
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: If the algorithm finishes and `Finish[i]` is still `false` for some process Pi, it means Pi's request could not be satisfied even after simulating all other possible completions. Thus, Pi is deadlocked.

Q11. What is the time complexity of this detection algorithm?

A.O(n)
B.O(m)
C.O(m Ɨ n²) āœ…
D.O(n³)
šŸ’” Difficulty: medium | āœ… Correct: C

šŸ“– Explanation: The algorithm involves iterating through processes and checking vectors of length m. The text states it requires an order of m Ɨ n² operations.

Q12. Why is the algorithm described as having an 'optimistic attitude'?

A.It assumes no deadlocks exist.
B.It assumes that if a process's current request is met, it will finish and release all resources. āœ…
C.It assumes all resources are free.
D.It assumes processes are honest.
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: The algorithm assumes that satisfying `Request_i` is enough for Pi to complete. It doesn't check if Pi will make *future* requests. It optimistically assumes Pi will return all `Allocation_i` soon. If Pi makes more requests later, a new detection cycle will handle it.

Q13. If the optimistic assumption is incorrect, what happens?

A.The system crashes.
B.The deadlock is missed forever.
C.The deadlock will be detected the next time the algorithm is invoked. āœ…
D.The process is terminated immediately.
šŸ’” Difficulty: hard | āœ… Correct: C

šŸ“– Explanation: If Pi finishes its current request but then requests more resources, causing a deadlock, this new state will be present in the system. The periodic or triggered invocation of the detection algorithm will catch this new deadlock in the subsequent run.

Q14. In the illustrative example, which sequence proves the system is NOT deadlocked initially?

A.<P0, P1, P2, P3, P4>
B.<P0, P2, P3, P1, P4> āœ…
C.<P4, P3, P2, P1, P0>
D.<P1, P2, P3, P4, P0>
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: The text explicitly states that the sequence <P0, P2, P3, P1, P4> results in `Finish[i] == true` for all i, proving the initial state is safe (not deadlocked).

Q15. In the example, after P2 requests one more C, which processes are deadlocked?

A.P0 only
B.P1, P2, P3, P4 āœ…
C.All processes
D.None
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: The text states that after P2's additional request, the system is deadlocked, consisting of processes P1, P2, P3, and P4. P0 is not deadlocked because it holds no resources and has no requests (Request 0,0,0), so it was marked finished initially.

Q16. What is the key difference between the `Request` matrix here and the `Need` matrix in Banker's Algorithm?

A.There is no difference.
B.`Request` is current demand; `Need` is maximum remaining demand. āœ…
C.`Request` is maximum demand; `Need` is current demand.
D.`Request` is for output; `Need` is for input.
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: Banker's `Need` is `Max - Allocation`, representing the worst-case future demand. The Detection `Request` is what the process is *currently* asking for right now. A process might have a large `Need` but a small `Request` if it asks for resources incrementally.

Q17. Can a process with `Allocation_i == 0` be deadlocked?

A.Yes, if it requests resources.
B.No, because it holds no resources to block others. āœ…
C.Yes, if it is waiting.
D.No, because it is finished.
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: In this specific algorithm, processes with zero allocation are marked `Finish=true` initially. They are not considered part of a deadlock cycle because they don't hold resources that others might be waiting for. If they request resources, they wait, but they don't cause a circular hold-and-wait themselves.

Q18. If `Request_i` is (0, 0, 0) for a process with `Allocation_i > 0`, what happens?

A.It is ignored.
B.It is selected if `Finish[i]==false`, as (0,0,0) ≤ Work is always true. āœ…
C.It causes an error.
D.It is marked as deadlocked.
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: If a process holds resources but requests nothing more, its `Request` is zero. Since `0 ≤ Work` is always true, it will be selected, its `Allocation` added to `Work`, and it will be marked finished. This simulates it completing and releasing resources.

Q19. What does `Request[i][j] = k` mean?

A.Pi has allocated k instances of Rj.
B.Pi may need k more instances of Rj in total.
C.Pi is currently requesting k instances of Rj. āœ…
D.Pi has released k instances of Rj.
šŸ’” Difficulty: easy | āœ… Correct: C

šŸ“– Explanation: The `Request` matrix entries indicate the *current* active request. `Request[i][j] = k` means process Pi is actively asking for k instances of resource type Rj at this moment.

Q20. If no index `i` is found in Step 2, what is the next step?

A.Restart.
B.Go to Step 4. āœ…
C.Declare system safe.
D.Terminate processes.
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: If the search fails to find a process whose request can be met, the algorithm proceeds to Step 4 to check the `Finish` array and determine which processes are deadlocked.

Q21. In Step 4, if `Finish[i] == false` for some i, the system is in what state?

A.Safe
B.Deadlocked āœ…
C.Unsafe
D.Stable
šŸ’” Difficulty: easy | āœ… Correct: B

šŸ“– Explanation: The presence of any `false` in `Finish` after the algorithm completes indicates that those processes could not complete, meaning the system is in a deadlocked state.

Q22. Why is `Work` increased by `Allocation_i` and not `Request_i`?

A.Because `Request` is negligible.
B.Because the process releases all its *held* resources (`Allocation`) upon completion, not just the requested ones. āœ…
C.Because `Request` is already in `Work`.
D.Because `Allocation` is smaller.
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: When a process completes, it returns all resources it was holding (`Allocation_i`) back to the system. The `Request_i` was just the extra bit it needed to finish. The total contribution to the available pool is its entire allocation.

Q23. Is this algorithm proactive or reactive?

A.Proactive
B.Reactive āœ…
C.Both
D.Neither
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: Deadlock detection is reactive. It examines the current state to see if a deadlock *has already occurred*. It does not prevent or avoid it beforehand.

Q24. What is the primary purpose of the `Finish` array?

A.To store resource counts.
B.To track which processes have been simulated to completion. āœ…
C.To store request vectors.
D.To count cycles.
šŸ’” Difficulty: easy | āœ… Correct: B

šŸ“– Explanation: The `Finish` array marks processes that have been successfully simulated as completing. If a process is marked true, it means it's not part of the deadlock.

Q25. If a system has 3 resource types and 5 processes, what is the size of the `Request` matrix?

A.3x5
B.5x3 āœ…
C.5x5
D.3x3
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: The `Request` matrix is n x m, where n is processes (5) and m is resource types (3). So it is a 5x3 matrix.

Q26. Can this algorithm identify *which* processes are deadlocked?

A.No, only that a deadlock exists.
B.Yes, those with `Finish[i] == false`. āœ…
C.Yes, those with `Finish[i] == true`.
D.Only the first one.
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: Step 4 explicitly states that if `Finish[i] == false`, then process Pi is deadlocked. This allows the system to identify the specific set of deadlocked processes.

Q27. Why is the initialization `Finish[i] = true` for `Allocation_i == 0` valid?

A.Because they are fast.
B.Because they hold no resources, so they cannot be part of a circular wait involving resource holding. āœ…
C.Because they are finished.
D.Because they have no requests.
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: Deadlock requires hold-and-wait. A process holding nothing (`Allocation=0`) cannot be the 'hold' part of a cycle that blocks others. It might wait, but it doesn't contribute to the resource scarcity causing the deadlock for others. Thus, it's safely excluded from the deadlock set.

Q28. If `Available` is (1, 1, 1) and `Request_P1` is (1, 1, 1), and `Allocation_P1` is (0, 0, 0). What happens to P1?

A.It is deadlocked.
B.It is selected, Work becomes (1,1,1)+(0,0,0)=(1,1,1), Finish[P1]=true. āœ…
C.It is skipped.
D.It causes an error.
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: Wait, if `Allocation_P1` is 0, `Finish[P1]` is initialized to `true`. It is already marked finished. It won't even be considered in Step 2. If `Allocation_P1` was >0, say (1,0,0), then `Finish` is false. `Request` (1,1,1) <= `Work` (1,1,1) is true. It would be selected. But with `Alloc=0`, it's already done.

Q29. What is the main advantage of this algorithm over Wait-For Graph for multiple instances?

A.It is faster.
B.It correctly detects deadlocks in multiple-instance systems. āœ…
C.It uses less memory.
D.It is simpler.
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: WFG fails for multiple instances. This algorithm, using the state-based approach similar to Banker's, correctly handles the complexity of multiple instances by checking if current requests can be satisfied by available resources plus released allocations.

Q30. If a process is deadlocked, what is its status in the `Finish` array?

A.true
B.false āœ…
C.Null
D.Zero
šŸ’” Difficulty: easy | āœ… Correct: B

šŸ“– Explanation: Deadlocked processes are those that could not be simulated to completion, so their `Finish` flag remains `false`.

Q31. Does the algorithm guarantee that non-deadlocked processes will finish?

A.Yes, in the simulation. āœ…
B.No.
C.Only if they are fast.
D.Only if they have high priority.
šŸ’” Difficulty: medium | āœ… Correct: A

šŸ“– Explanation: The algorithm finds a sequence where all non-deadlocked processes *can* finish. It proves their feasibility. In reality, they might still be running, but the algorithm confirms they are not stuck in the current deadlock.

Q32. What happens if `Request_i` > `Work` for all unfinished processes?

A.The algorithm stops and declares all unfinished processes deadlocked. āœ…
B.The algorithm continues.
C.The system reboots.
D.Resources are added.
šŸ’” Difficulty: hard | āœ… Correct: A

šŸ“– Explanation: If no process can be found in Step 2 (because all remaining requests exceed `Work`), the loop ends, and Step 4 identifies all remaining `Finish[i]==false` processes as deadlocked.

Q33. Is the `Request` matrix static or dynamic?

A.Static
B.Dynamic āœ…
C.Constant
D.Fixed
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: `Request` changes as processes make new requests or have their current requests granted. It reflects the *current* state of pending requests.

Q34. In the example, why was P0 not part of the deadlock after P2's request?

A.Because P0 had no resources and no requests. āœ…
B.Because P0 was fast.
C.Because P0 was privileged.
D.Because P0 released resources.
šŸ’” Difficulty: hard | āœ… Correct: A

šŸ“– Explanation: P0 had `Allocation` (0,1,0) wait, let's check the table. P0 Alloc: 0,1,0. Request: 0,0,0. Since Request is 0,0,0, P0 can always be satisfied (0<=Work). So P0 finishes, releases (0,1,0). It is not deadlocked. The text says P0 is reclaimed. Wait, the text says 'Although we can reclaim the resources held by process P0...'. P0 has Alloc 0,1,0. Request 0,0,0. So P0 finishes early. It is not in the deadlocked set {P1, P2, P3, P4}.

Q35. What is the role of the `Available` vector in the detection algorithm?

A.It sets the initial `Work`. āœ…
B.It stores max needs.
C.It stores allocations.
D.It stores requests.
šŸ’” Difficulty: easy | āœ… Correct: A

šŸ“– Explanation: `Available` provides the starting point for the `Work` vector, representing the resources currently free in the system before any simulated completions.

Q36. If a system is in a deadlocked state, can any process proceed?

A.Yes, all can.
B.No, the deadlocked processes cannot proceed.
C.Yes, non-deadlocked ones can. āœ…
D.No, none can.
šŸ’” Difficulty: medium | āœ… Correct: C

šŸ“– Explanation: The algorithm identifies *which* processes are deadlocked. Processes not in the deadlocked set (those with `Finish[i]=true`) are not blocked by the deadlock and can potentially proceed if their requests are met.

Q37. Why is the complexity O(m Ɨ n²)?

A.Because it checks m resources for n processes in a nested loop structure. āœ…
B.Because it sorts the processes.
C.Because it multiplies matrices.
D.Because it uses recursion.
šŸ’” Difficulty: medium | āœ… Correct: A

šŸ“– Explanation: The algorithm iterates through processes (n) and for each, compares vectors of length m. In the worst case, it might scan all processes for each completion, leading to n * n * m operations.

Q38. Can this algorithm be used for single-instance systems?

A.Yes, but WFG is more efficient. āœ…
B.No, it fails.
C.Yes, and it is faster.
D.No, it is too complex.
šŸ’” Difficulty: medium | āœ… Correct: A

šŸ“– Explanation: It *can* work, as single-instance is a subset of multiple-instance (where max is 1). However, the WFG method is simpler and faster (O(n²) vs O(m*n²)) for single instances, so WFG is preferred there.

Q39. What is the 'optimistic' aspect of reclaiming resources in Step 3?

A.Assuming the process will not request more resources. āœ…
B.Assuming the process will crash.
C.Assuming the process is fast.
D.Assuming the resources are free.
šŸ’” Difficulty: hard | āœ… Correct: A

šŸ“– Explanation: The algorithm assumes that satisfying the *current* `Request` is sufficient for the process to complete and release *all* its `Allocation`. It ignores the possibility of future requests, which is an optimistic simplification.

Q40. If `Finish[i]` is true for all i, what is the system state?

A.Deadlocked
B.Not Deadlocked āœ…
C.Unsafe
D.Unknown
šŸ’” Difficulty: easy | āœ… Correct: B

šŸ“– Explanation: If all processes are marked finished, it means a sequence exists where all can complete. Therefore, no deadlock exists.

Q41. What data structure is NOT used in this detection algorithm?

A.Available
B.Allocation
C.Max āœ…
D.Request
šŸ’” Difficulty: easy | āœ… Correct: C

šŸ“– Explanation: The algorithm uses `Available`, `Allocation`, and `Request`. It does not use `Max` or `Need`, distinguishing it from the Banker's Algorithm.

Q42. If a process P5 is added to the system, how does the algorithm change?

A.n increases, matrix sizes increase. āœ…
B.m increases.
C.Nothing changes.
D.It becomes slower.
šŸ’” Difficulty: medium | āœ… Correct: A

šŸ“– Explanation: Adding a process increases n. The `Allocation` and `Request` matrices gain a row. The `Finish` array gains an element. The complexity O(m*n²) increases.

Q43. In the example, what is the `Request` for P1?

A.(2, 0, 2) āœ…
B.(0, 0, 0)
C.(1, 0, 0)
D.(0, 0, 2)
šŸ’” Difficulty: easy | āœ… Correct: A

šŸ“– Explanation: Looking at the table provided in the text for the initial state, P1's Request is listed as 2, 0, 2.

Q44. Why is P2's additional request for C significant in the example?

A.It reduces Available C to a level where other requests cannot be met. āœ…
B.It increases Available C.
C.It frees resources.
D.It has no effect.
šŸ’” Difficulty: hard | āœ… Correct: A

šŸ“– Explanation: Initially, Available was (0,0,0) wait, let's check. Initial Available: 0,0,0? No, the table shows Available ABC. Let's look at the text. 'Resource type A has seven... B two... C six'. Alloc sum: A: 0+2+3+2+0=7. B: 1+0+0+1+0=2. C: 0+0+3+1+2=6. So Available is (0,0,0). Wait, the table says Available 0,0,0. Then P2 requests 1 more C. Request P2 becomes 0,0,1. Now, can anyone run? P0 Req 0,0,0. Runs. Releases 0,1,0. Avail 0,1,0. P3 Req 1,0,0. 1>0 A. Fail. P1 Req 2,0,2. Fail. P4 Req 0,0,2. 2>0 C. Fail. P2 Req 0,0,1. 1>0 C. Fail. Only P0 ran. Avail 0,1,0. No one else can run. Deadlock.

Q45. What is the condition `Request_i ≤ Work` checking?

A.If the process has enough resources.
B.If the system can satisfy the process's current request. āœ…
C.If the process is finished.
D.If the process is deadlocked.
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: It checks if the currently available simulated resources (`Work`) are sufficient to grant the process's pending request (`Request_i`). If yes, the process can potentially proceed.

Q46. If a process is deadlocked, does it mean it is terminated?

A.Yes, immediately.
B.No, detection only identifies it. Recovery terminates it. āœ…
C.Yes, if it is slow.
D.No, it continues.
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: Detection only *identifies* the deadlock. It does not take action to resolve it. The Recovery phase (separate from detection) would handle termination or preemption.

Q47. Can the algorithm detect partial deadlocks?

A.No, only full system deadlocks.
B.Yes, it identifies specific deadlocked processes. āœ…
C.Yes, but only if all are deadlocked.
D.No.
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: The algorithm marks specific `Finish[i]` as false. These are the deadlocked processes. Others may be fine. Thus, it detects partial deadlocks involving a subset of processes.

Q48. What is the primary input to the detection algorithm?

A.Current state (Available, Allocation, Request). āœ…
B.Maximum needs.
C.Past history.
D.Future predictions.
šŸ’” Difficulty: easy | āœ… Correct: A

šŸ“– Explanation: The algorithm operates on the current snapshot of the system: what is available, what is allocated, and what is currently being requested.

šŸ”— Related Topics (MCQs)