📝 Resource Preemption and Recovery from Deadlock (23 MCQs)
📖 From Operating System • 7. Deadlocks • 23 questions available
What is Resource Preemption and Recovery from Deadlock?
Definition:
Preemption forcibly takes resources from deadlocked processes and allocates them to others, potentially rolling back the preempted process to a safe checkpoint.
Example:
Preempt resource from , save state to checkpoint , and restart later from when becomes available.
Reason:
Preemption avoids process termination and preserves computation, but introduces complexity in rollback management and risks starvation if the same process is repeatedly selected as victim.
📝 All Resource Preemption and Recovery from Deadlock MCQs
Q1. What is the fundamental approach of resource preemption for deadlock resolution?
📖 Explanation: Resource preemption resolves deadlocks by taking resources away from some processes and giving them to others until the circular wait condition is broken. This is done successively, meaning resources are preempted one step at a time rather than all at once.
Q2. What condition must be met for resource preemption to successfully eliminate deadlock?
📖 Explanation: Resource preemption continues until the deadlock cycle is broken. Each preemption step reduces the circular wait condition, and the process repeats until the cycle no longer exists. This may require multiple preemptions depending on the complexity of the deadlock cycle.
Q3. How does resource preemption differ from process termination in deadlock handling?
📖 Explanation: Process termination removes entire processes and all their resources, while resource preemption selectively removes specific resources from processes while allowing the processes to continue after rollback. Preemption is more surgical and may preserve more computational work, but requires complex rollback mechanisms.
Q4. What is a victim in the context of resource preemption?
📖 Explanation: In resource preemption, a victim is a process selected to have some of its resources taken away to break the deadlock cycle. The victim is chosen based on cost factors to minimize the overall impact of the preemption on system performance.
Q5. Which cost factor is considered when selecting a victim for resource preemption?
📖 Explanation: When selecting a victim, the system considers the number of resources a deadlocked process is holding. Processes holding more resources may be more costly to preempt because reclaiming and reallocating multiple resources involves more overhead and complexity.
Q6. What is the primary goal when selecting a victim for resource preemption?
📖 Explanation: The primary goal is to minimize the cost of preemption by selecting processes whose resource preemption causes the least disruption. This economic decision considers factors like resources held, computation time consumed, and the impact on overall system performance.
Q7. Why is the amount of time a process has consumed considered in victim selection?
📖 Explanation: The time a process has consumed represents computational work already performed. Preempting resources from a process that has consumed significant CPU time may waste substantial computational effort, making it a more expensive victim choice than a process with less invested computation.
Q8. How do cost factors in victim selection relate to process termination decisions?
📖 Explanation: Both victim selection in resource preemption and process termination decisions involve economic considerations. They evaluate similar cost factors like resources held, computation time, and process importance to determine which action minimizes system disruption and wasted work.
Q9. When a resource is preempted from a process, what must happen to that process?
📖 Explanation: When a resource is preempted from a process, the process cannot continue normal execution because it's missing a needed resource. The process must be rolled back to a safe state where it had all necessary resources, and then restarted from that point to ensure correct execution.
Q10. What is the simplest solution for rollback after resource preemption?
📖 Explanation: The simplest rollback solution is total rollback, where the process is aborted and then completely restarted. This approach is straightforward to implement but inefficient because it discards all progress made by the process, including work that could have been preserved with more sophisticated rollback methods.
Q11. What is the main disadvantage of total rollback after resource preemption?
📖 Explanation: Total rollback discards all work performed by the process before the preemption occurred. This can be highly inefficient, especially for processes that have been executing for long periods or have accumulated significant partial results, as all that computation must be redone from the beginning.
Q12. What additional information must the system maintain for partial rollback compared to total rollback?
📖 Explanation: Partial rollback requires the system to maintain detailed state information about all running processes to know exactly how far to roll back each process. This includes tracking resource allocation history, instruction boundaries, and process state at various checkpoints, which adds significant system overhead and complexity.
Q13. Why is partial rollback more effective than total rollback despite being more complex?
📖 Explanation: Partial rollback is more effective because it preserves some of the computational work already performed. By rolling back only as far as necessary to break the deadlock, the system can restart processes from a point where they still have valid progress, rather than discarding all work through total rollback.
Q14. What is starvation in the context of resource preemption?
📖 Explanation: Starvation occurs when the same process is repeatedly selected as a victim for resource preemption. This prevents the process from ever completing its designated task because it continuously loses resources and must restart, making no progress toward completion.
Q15. Why might the same process always be picked as a victim in resource preemption?
📖 Explanation: If victim selection is based primarily on cost factors, the algorithm may consistently choose the same process if it consistently appears as the lowest-cost victim. This creates an unintended bias in the selection process, leading to starvation for that particular process.
Q16. What is the most common solution to prevent starvation in resource preemption?
📖 Explanation: The most common solution is to include the number of times a process has been rolled back as a cost factor in victim selection. This effectively increases the cost of repeatedly choosing the same process, making it less attractive as a victim after each rollback and ensuring fair distribution of preemption.
Q17. How does including rollback count in the cost factor prevent starvation?
📖 Explanation: By including rollback count as a cost factor, processes that have been victimized multiple times become more expensive to preempt. This gradually biases the selection algorithm away from frequently victimized processes, ensuring that no single process suffers from continuous resource preemption and ultimately experiences starvation.
Q18. In total rollback after resource preemption, what happens to the process's resources?
📖 Explanation: In total rollback, the process is aborted and then restarted. The system reclaims all resources previously allocated to the process, making them available for other processes or for the same process after restart. This approach is simple but discards all progress the process had made.
Q19. What is the primary advantage of total rollback as a rollback strategy?
📖 Explanation: Total rollback is simple to implement because the system only needs to abort and restart the process. There's no need to maintain detailed state information or determine how far to roll back, making it straightforward for operating system designers to implement this approach.
Q20. In what scenario would total rollback be the preferred rollback strategy?
📖 Explanation: Total rollback is preferred when simplicity of implementation is more important than preserving computational work. Systems that prioritize ease of design and low overhead over efficiency may choose total rollback despite its wastefulness, especially in environments where processes are short-lived or work can be easily recomputed.
Q21. What challenge does partial rollback present to operating system designers?
📖 Explanation: Partial rollback requires the system to determine exactly how far back to roll each process to break the deadlock while preserving as much work as possible. This is challenging because it requires detailed tracking of process state, resource usage history, and execution progress, which adds significant complexity to the operating system.
Q22. Why does partial rollback require the system to keep more information about running processes?
📖 Explanation: Partial rollback requires detailed process state information to know exactly where to restore execution. This includes tracking resource allocation sequences, instruction pointers, register states, and memory contents at various checkpoints. The system must maintain this comprehensive state information to perform precise rollback operations.
Q23. What trade-off exists between total and partial rollback strategies?
📖 Explanation: Partial rollback preserves more computational work by rolling back only to necessary points, but this comes at the cost of maintaining extensive state information about each process. Total rollback is simpler to implement but discards all work. The trade-off is between computational efficiency and system complexity.