Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
DeadlocksEasy
Q1. A deadlock occurs when:
- A.Processes wait indefinitely for resources held by each other✓ Correct
- B.A process enters an infinite loop consuming all CPU time
- C.The CPU is overloaded with too many running processes
- D.A process terminates unexpectedly due to an error
Explanation
A deadlock is a situation where two or more processes are each waiting for a resource held by another process in the set, creating a circular wait where none can proceed.
Report an error in this question
DeadlocksEasy
Q2. How many necessary conditions must hold simultaneously for a deadlock to occur?
- A.Three
- B.Four✓ Correct
- C.Two
- D.Five
Explanation
Four conditions must hold simultaneously: mutual exclusion, hold and wait, no preemption, and circular wait. These are known as the Coffman conditions.
Report an error in this question
DeadlocksEasy
Q3. Which of the following is NOT a necessary condition for deadlock?
- A.Mutual exclusion
- B.Hold and wait
- C.Circular wait
- D.Preemption✓ Correct
Explanation
The four necessary conditions are: mutual exclusion, hold and wait, NO preemption (not preemption), and circular wait. Preemption would actually help prevent deadlock.
Report an error in this question
DeadlocksEasy
Q4. The 'hold and wait' condition means:
- A.A process waits without holding any resource
- B.A process holds no resources at all currently
- C.A process releases all resources before waiting
- D.A process holds resources while waiting for more✓ Correct
Explanation
Hold and wait means a process is holding at least one resource and is waiting to acquire additional resources that are currently being held by other processes.
Report an error in this question
DeadlocksEasy
Q5. Circular wait means:
- A.Processes are scheduled in a circular fashion
- B.Each process waits for the next, forming a cycle✓ Correct
- C.Processes simply wait in a standard queue
- D.Only one single process is actively waiting
Explanation
Circular wait exists when there is a chain of processes P0, P1, ..., Pn where P0 waits for a resource held by P1, P1 waits for P2, and so on, with Pn waiting for P0.
Report an error in this question
DeadlocksEasy
Q6. Deadlock prevention works by:
- A.Ignoring deadlocks entirely and hoping they pass
- B.Ensuring at least one necessary condition fails✓ Correct
- C.Recovering from deadlocks by terminating tasks
- D.Detecting deadlocks after they already occurred
Explanation
Deadlock prevention ensures that at least one of the four necessary conditions (mutual exclusion, hold and wait, no preemption, circular wait) cannot hold, making deadlock structurally impossible.
Report an error in this question
DeadlocksEasy
Q7. A resource allocation graph is used to:
- A.Display the memory layout of processes
- B.Represent resource allocation and requests✓ Correct
- C.Show the CPU scheduling execution order
- D.Show the file system directory structure
Explanation
A resource allocation graph uses vertices (processes and resources) and edges (request edges from process to resource, assignment edges from resource to process) to represent the allocation state.
Report an error in this question
DeadlocksEasy
Q8. If a resource allocation graph has no cycle, then:
- A.Deadlock definitely exists in system
- B.Deadlock may or may not exist here
- C.Deadlock definitely does not exist✓ Correct
- D.The resource allocation graph invalid
Explanation
If the resource allocation graph contains no cycle, then no deadlock exists. A cycle is a necessary condition for deadlock. However, a cycle does not always guarantee deadlock.
Report an error in this question
DeadlocksEasy
Q9. Deadlock avoidance requires:
- A.Advance info about resource requests✓ Correct
- B.Using only one resource at a time
- C.Killing processes periodically needed
- D.No additional information at all
Explanation
Deadlock avoidance requires advance information about the maximum resource needs of each process. The system uses this to make decisions that ensure it never enters an unsafe state.
Report an error in this question
DeadlocksEasy
Q10. The Banker's Algorithm is used for:
- A.Checking if granting request is safe✓ Correct
- B.Processing banking transactions safely
- C.Memory allocation for new processes
- D.CPU scheduling of running processes
Explanation
The Banker's Algorithm is a deadlock avoidance algorithm that checks whether granting a resource request would leave the system in a safe state. If not, the request is denied.
Report an error in this question
DeadlocksMedium
Q11. A safe state is one where:
- A.A safe sequence exists for all processes✓ Correct
- B.No process is waiting for any resource
- C.All system resources are fully available
- D.No process is currently running at all
Explanation
A state is safe if there exists a sequence of all processes such that each process can be allocated its needed resources (from available + resources held by preceding processes in the sequence) to complete.
Report an error in this question
DeadlocksMedium
Q12. What is the relationship between safe state and deadlock?
- A.An unsafe state always guarantees that deadlock exists
- B.Safe state means deadlock currently exists in system
- C.Safe and unsafe states are unrelated to deadlock at all
- D.Safe means no deadlock; unsafe means deadlock may occur✓ Correct
Explanation
A safe state guarantees no deadlock. An unsafe state does not guarantee deadlock but means deadlock is possible. Deadlock avoidance ensures the system never enters an unsafe state.
Report an error in this question
DeadlocksMedium
Q13. To prevent the 'hold and wait' condition, a process must:
- A.Use only shared resources that do not need locking
- B.Never request any resources from the operating system
- C.Request all resources at once, or release before requesting✓ Correct
- D.Hold all needed resources indefinitely without releasing
Explanation
To prevent hold and wait: either a process requests all resources before starting (may cause low utilization) or it must release all currently held resources before requesting new ones.
Report an error in this question
DeadlocksMedium
Q14. To prevent circular wait, one approach is:
- A.Remove all shared resources from system
- B.Allow processes to request in any order
- C.Impose ordering and require increasing order✓ Correct
- D.Use only a single resource type allowed
Explanation
To prevent circular wait, assign a numerical ordering to all resource types and require that processes request resources in strictly increasing order of their assigned numbers.
Report an error in this question
DeadlocksMedium
Q15. In the Banker's Algorithm, the 'Need' matrix represents:
- A.Currently allocated resources to each process
- B.The total number of resources in whole system
- C.Remaining resources each process may still need✓ Correct
- D.Total resources currently available to allocate
Explanation
The Need matrix = Max - Allocation. It represents the remaining resources that each process may still request to complete its task. Need[i][j] = Max[i][j] - Allocation[i][j].
Report an error in this question
DeadlocksMedium
Q16. What is deadlock detection?
- A.Allowing deadlocks then detecting and recovering✓ Correct
- B.Ignoring deadlocks completely in all situations
- C.Avoiding deadlocks using the Banker Algorithm
- D.Preventing deadlocks from occurring in system
Explanation
Deadlock detection allows deadlocks to occur but uses algorithms to periodically check for deadlocks and then applies recovery techniques (process termination or resource preemption) to resolve them.
Report an error in this question
DeadlocksMedium
Q17. For deadlock detection with single-instance resources, which algorithm is used?
- A.Wait-for graph cycling✓ Correct
- B.Banker's Algorithm test
- C.Round Robin scheduling
- D.Best Fit allocating
Explanation
For single-instance resources, a wait-for graph is used. It is a variant of the resource allocation graph where resource nodes are removed. A cycle in the wait-for graph indicates deadlock.
Report an error in this question
DeadlocksMedium
Q18. Which deadlock recovery method terminates processes?
- A.Resource preemption from deadlocked processes
- B.Restarting the entire system from the beginning
- C.Ignoring the deadlock and hoping it resolves
- D.Process termination - abort all or one at a time✓ Correct
Explanation
Process termination can abort all deadlocked processes (expensive) or terminate one process at a time until the deadlock is broken (requires re-running detection after each termination).
Report an error in this question
DeadlocksMedium
Q19. When recovering from deadlock by process termination, which factor is NOT typically considered?
- A.Time it has been running
- B.Process priority level
- C.Resources it now holds
- D.The color of terminal✓ Correct
Explanation
When selecting a process to terminate, factors include priority, computation time completed, resources held, resources needed, number of processes to terminate, and whether it is interactive or batch.
Report an error in this question
DeadlocksMedium
Q20. The ostrich algorithm for handling deadlocks refers to:
- A.Ignoring deadlocks when rare and costly to handle✓ Correct
- B.A recovery mechanism for resolving deadlocks
- C.A sophisticated deadlock detection algorithm
- D.A prevention technique eliminating conditions
Explanation
The ostrich algorithm simply ignores deadlocks ('burying its head in the sand'). It is used when deadlocks are very rare and the cost of prevention, avoidance, or detection is deemed too high. Used by most general-purpose OSes.
Report an error in this question
DeadlocksHard
Q21. In the Banker's Algorithm safety check, what is the time complexity for n processes and m resource types?
- A.O(n) linear
- B.O(n!) factorial
- C.O(n * m) time
- D.O(n^2 * m) time✓ Correct
Explanation
The Banker's Algorithm safety check has time complexity O(n^2 * m) because in the worst case, it needs to scan all n processes n times (each scan finds at least one process that can finish), and each comparison involves m resource types.
Report an error in this question
DeadlocksHard
Q22. What is the problem with resource preemption as a deadlock recovery method?
- A.It uses too much memory for tracking state
- B.Selecting victim, rollback, preventing starvation✓ Correct
- C.It only works on single-processor systems
- D.It runs too fast and is hard to control
Explanation
Resource preemption challenges include: selecting which process to preempt (cost minimization), rolling back the preempted process to a safe state, and ensuring the same process isn't always selected (starvation).
Report an error in this question
DeadlocksHard
Q23. In a resource allocation graph with multiple instances per resource type, a cycle:
- A.Necessary but not sufficient✓ Correct
- B.Never indicates any deadlock
- C.Always indicates deadlock
- D.Neither necessary nor sufficient
Explanation
With multiple instances per resource type, a cycle is necessary but not sufficient for deadlock. A cycle may exist without deadlock if other processes can release resources to break the wait.
Report an error in this question
DeadlocksHard
Q24. What is a livelock and how does it differ from deadlock?
- A.There is no difference between livelock and deadlock
- B.Livelock only occurs in single-threaded programs only
- C.In livelock processes change state without any progress✓ Correct
- D.Livelock is simply a faster form of deadlock occurring
Explanation
In a livelock, processes are not blocked but continuously change their states in response to each other without making any real progress. Unlike deadlock, the processes are active but unproductive.
Report an error in this question
DeadlocksHard
Q25. How does the 'no preemption' condition get addressed in deadlock prevention for resources like CPU registers and memory?
- A.All held resources are preempted if request fails✓ Correct
- B.The process is immediately terminated by the OS
- C.These resources can never be preempted at all
- D.The resources are duplicated for both processes
Explanation
For preemptable resources: if a process requests a resource that is unavailable, its currently held resources are implicitly released (preempted) and added to the list of available resources.
Report an error in this question
DeadlocksHard
Q26. What is the main limitation of the Banker's Algorithm in practice?
- A.It runs too fast for real world use cases
- B.It only works with exactly two processes
- C.Processes rarely know max needs in advance✓ Correct
- D.It does not detect any resource cycles found
Explanation
The Banker's Algorithm requires each process to declare maximum resource needs in advance, which is often impractical. Additionally, the number of processes and resources changes dynamically in real systems.
Report an error in this question
DeadlocksHard
Q27. How frequently should a deadlock detection algorithm be invoked?
- A.Only when the system is shutting down
- B.Depends on frequency and tradeoff of cost✓ Correct
- C.Every single millisecond without exception
- D.Once at initial system startup only ever
Explanation
Detection frequency is a tradeoff: invoke at every resource request (expensive), at fixed intervals, or when CPU utilization drops below a threshold (suggesting possible deadlock). The choice depends on system characteristics.
Report an error in this question
DeadlocksHard
Q28. In distributed systems, what additional challenges does deadlock detection face?
- A.Deadlocks cannot occur in distributed systems
- B.Only overall performance is affected here
- C.No additional challenges at all exist
- D.Delays, no global state, phantom deadlocks✓ Correct
Explanation
In distributed systems, deadlock detection is complicated by communication delays, the absence of a global state, and the possibility of phantom (false) deadlocks detected due to outdated or inconsistent information across nodes.
Report an error in this question
DeadlocksHard
Q29. What is a two-phase locking protocol and how does it relate to deadlocks?
- A.A protocol using only two shared resources
- B.A protocol with exactly two locks only
- C.Growing acquires, shrinking releases; can deadlock✓ Correct
- D.A protocol that is completely deadlock-free
Explanation
Two-phase locking has a growing phase (acquiring locks, no releases) and shrinking phase (releasing locks, no acquisitions). It ensures serializability but does not prevent deadlocks - processes can deadlock while in the growing phase.
Report an error in this question
DeadlocksHard
Q30. What is the wound-wait scheme for deadlock prevention in database systems?
- A.Older wounds younger; younger waits for older✓ Correct
- B.A recovery technique for crashed transactions
- C.A method to wound and terminate processes
- D.A scheduling algorithm for query processing
Explanation
In wound-wait: if an older transaction needs a resource held by a younger one, the younger is 'wounded' (rolled back). If a younger transaction needs a resource held by an older one, it waits. This prevents circular wait.
Report an error in this question