📝 Recovery from Deadlock in Operating System (41 MCQs)
📖 From Operating System • 7. Deadlocks • 41 questions available
What is Recovery from Deadlock in Operating System?
Definition:
Recovery mechanisms restore normal system operation after deadlock detection by either terminating processes or preempting resources.
Example:
Upon detecting deadlock set , the OS selects victim for termination or resource stripping.
Reason:
Without recovery, detected deadlocks persist indefinitely; recovery policies determine the fairness, efficiency, and data integrity consequences of resolution.
📝 All Recovery from Deadlock in Operating System MCQs
Q1. What triggers the recovery process from a deadlock?
📖 Explanation: Recovery is a reactive measure. It is initiated only after the deadlock detection algorithm has examined the system state and confirmed that a deadlock currently exists.
Q2. Which of the following is NOT a general approach to handling a detected deadlock?
📖 Explanation: Prevention is a proactive strategy used before deadlocks occur. Once a deadlock is detected, the options are manual intervention, automatic recovery via abortion, or automatic recovery via preemption.
Q3. In the manual recovery approach, who is responsible for breaking the deadlock?
📖 Explanation: Manual recovery involves informing the human operator that a deadlock has occurred. The operator then analyzes the situation and takes appropriate actions (e.g., killing processes) to resolve it.
Q4. What is a potential disadvantage of manual recovery?
📖 Explanation: Relying on an operator means the system may remain deadlocked for a significant time while waiting for human response. This delays resolution and keeps resources idle longer than an automatic system might.
Q5. What are the two primary automatic options for breaking a deadlock?
📖 Explanation: The text explicitly identifies two automatic methods: aborting one or more processes to break the circular wait, and preempting resources from deadlocked processes.
Q6. How does aborting processes break a deadlock?
📖 Explanation: When a process is aborted, the operating system reclaims all resources allocated to it. These freed resources can then be allocated to other waiting processes, breaking the circular wait condition.
Q7. What is resource preemption in the context of deadlock recovery?
📖 Explanation: Preemption involves the system forcibly seizing resources from one or more deadlocked processes and giving them to other processes in the cycle to allow them to proceed, thus breaking the deadlock.
Q8. Why might a system choose automatic recovery over manual recovery?
📖 Explanation: Automatic recovery allows the system to resolve deadlocks immediately without waiting for an operator. This minimizes downtime and resource idleness, which is crucial for unattended or real-time systems.
Q9. If a process is aborted, what happens to its computation progress?
📖 Explanation: Aborting a process terminates it immediately. Any work done since the last save point (checkpoint) is lost. This is a significant cost associated with process abortion.
Q10. What is a major challenge associated with resource preemption?
📖 Explanation: If a resource is taken from a process mid-operation, that process may be left in an inconsistent state. The system must be able to roll back the process to a previous safe state where it didn't hold the preempted resource, which is complex.
Q11. Which recovery method involves selecting a 'victim' process?
📖 Explanation: Both methods require selecting victims. In abortion, you select which process(es) to kill. In preemption, you select which process(es) to take resources from. Selection criteria often involve cost factors like priority or execution time.
Q12. Is it always necessary to abort ALL processes in a deadlock cycle?
📖 Explanation: Breaking the circular wait only requires removing one link in the chain. Aborting just one process in the cycle releases its resources, allowing others to proceed. Aborting all is unnecessary and more costly.
Q13. What is the risk of starving a process during recovery?
📖 Explanation: If the same process is consistently chosen as the victim for abortion or preemption due to low priority or other criteria, it may never make progress. This is known as starvation.
Q14. Why is manual recovery rarely used in modern high-availability systems?
📖 Explanation: High-availability systems require minimal downtime. Manual intervention introduces unpredictable delays and potential for human error, making automatic recovery mechanisms preferable.
Q15. What determines which process to abort in an automatic scheme?
📖 Explanation: Systems use cost functions to minimize disruption. Factors include process priority (kill low priority first), how long it has run (kill newer ones to save work), and how many resources it holds (kill those holding fewest to free least).
Q16. Can resource preemption cause a process to fail?
📖 Explanation: Some applications are not designed to handle having resources taken away unexpectedly. Preempting a critical resource (like a locked database record) without proper rollback mechanisms can cause the process to crash or produce incorrect results.
Q17. What is the primary goal of any deadlock recovery method?
📖 Explanation: The fundamental objective is to resolve the deadlock condition (circular wait) so that the involved processes (or at least the remaining ones) can continue execution and the system can return to normal operation.
Q18. If a system uses process abortion, what must happen to the resources held by the aborted process?
📖 Explanation: Upon termination, the operating system reclaims all resources owned by the process. These resources become available again for allocation to other processes, helping to resolve the deadlock.
Q19. Which method is generally considered more complex to implement correctly?
📖 Explanation: Preemption requires sophisticated mechanisms to safely take resources, roll back processes to consistent states, and potentially restart them. Abortion is simpler: just terminate and clean up. Manual is simplest but slowest.
Q20. What is a 'rollback' in the context of resource preemption?
📖 Explanation: When a resource is preempted, the process holding it may be in an invalid state. Rollback involves reverting the process to a checkpoint or safe state where it did not hold the preempted resource, allowing it to retry later.
Q21. Why might aborting a process be preferred over preemption?
📖 Explanation: Abortion simply ends the process. There is no need to worry about restoring a consistent state for that specific process because it is gone. Preemption requires careful state management to avoid corruption.
Q22. If a deadlock involves 5 processes, what is the minimum number of processes that must be aborted to guarantee breaking the deadlock?
📖 Explanation: Aborting just one process breaks the cycle. The resources it held are released, allowing the next process in the chain to proceed, which then releases its resources, and so on.
Q23. What is the impact of frequent process abortions on system throughput?
📖 Explanation: Each aborted process represents wasted CPU time and resources. Frequent abortions mean the system is spending significant effort on work that is never completed, reducing overall effective throughput.
Q24. Can a system combine both abortion and preemption?
📖 Explanation: A sophisticated recovery system might try preemption first for critical processes and resort to abortion if preemption fails or is too costly. Or it might abort low-priority processes and preempt from high-priority ones.
Q25. What information is needed to select a victim for abortion?
📖 Explanation: To make an intelligent decision, the system needs data about each process: its priority (don't kill critical services), how long it has run (don't kill nearly-finished tasks), and resources held.
Q26. Why is starvation a concern in deadlock recovery?
📖 Explanation: If the victim selection algorithm consistently picks the same process (e.g., the lowest priority one), that process may be repeatedly aborted or preempted, preventing it from ever finishing its task.
Q27. What is the role of the operator in manual recovery?
📖 Explanation: The operator receives the alert, examines which processes are deadlocked, and decides which to kill or how to intervene to break the cycle.
Q28. Which recovery method is most suitable for batch processing systems?
📖 Explanation: In batch systems, jobs can often be restarted easily. Aborting a job and resubmitting it is often simpler and safer than trying to preempt resources and roll back complex state in an interactive environment.
Q29. Which recovery method is most suitable for interactive/real-time systems?
📖 Explanation: Interactive users expect continuity. Aborting their process is frustrating. Preemption with rollback allows the system to resolve the deadlock while potentially preserving the user's session state, though it is complex.
Q30. What happens if no victim can be safely aborted or preempted?
📖 Explanation: In extreme cases, if all processes are critical and cannot be rolled back or lost, automatic recovery may fail. This might necessitate a full system restart or heavy manual intervention.
Q31. Does deadlock recovery guarantee that deadlocks will not happen again?
📖 Explanation: Recovery fixes the *current* deadlock. It does not change the underlying resource allocation patterns that caused it. Unless prevention/avoidance is also used, deadlocks can recur.
Q32. What is the 'cost' of a victim process?
📖 Explanation: The cost function estimates the disruption caused by selecting a process as a victim. Lower cost means less impact (e.g., low priority, short run time), making it a better candidate for abortion/preemption.
Q33. Why is preempting resources from a process difficult?
📖 Explanation: Simply taking a resource isn't enough. The process using it might have modified shared data. The system must ensure that taking the resource doesn't corrupt the system state, often requiring complex rollback protocols.
Q34. If a process is aborted, do its child processes survive?
📖 Explanation: In most operating systems, terminating a parent process results in the termination of its child processes (orphaned processes are adopted by init, but often killed if they depend on the parent). This amplifies the cost of abortion.
Q35. What is the primary advantage of resource preemption over abortion?
📖 Explanation: Preemption aims to save the process. By rolling back and retrying, the process can eventually complete its task. Abortion discards all progress, requiring a full restart.
Q36. Can deadlock recovery be fully transparent to the user?
📖 Explanation: If preemption and rollback are handled smoothly, the user might experience a slight delay but no loss of work or visible error. Abortion usually results in visible failure (program crash).
Q37. What is the relationship between detection and recovery?
📖 Explanation: Detection is the diagnostic phase (finding the deadlock). Recovery is the therapeutic phase (fixing the deadlock). They are sequential steps in handling deadlocks.
Q38. Why is 'doing nothing' (Ostrich Algorithm) sometimes considered a form of recovery?
📖 Explanation: In some systems (like personal PCs), the OS ignores deadlocks. The 'recovery' is left entirely to the user (manual recovery) who notices the freeze and reboots or kills tasks. It's a passive form of manual recovery.
Q39. What is the main trade-off in choosing a victim?
📖 Explanation: You want to pick the lowest-cost victim to minimize disruption. However, if you always pick the same low-cost one, it starves. You must balance efficiency with fairness.
Q40. If a system recovers from deadlock by aborting processes, what is the likely user experience?
📖 Explanation: Abortion kills the application. Users lose any unsaved data in that application and must restart it. This is disruptive and frustrating.
Q41. What is the significance of 'breaking the circular wait'?
📖 Explanation: Deadlock is defined by circular wait. Breaking this circle (by releasing resources via abortion or preemption) removes the necessary condition for deadlock, allowing the blocked processes to move forward.