🎓 BookMCQ
← Back to 5. Process Synchronization

📝 Deadlocks and Starvation in Semaphore (52 MCQs)

📖 From Operating System • 5. Process Synchronization • 52 questions available

What is Deadlocks and Starvation in Semaphore?

Definition:
Deadlock occurs when processes wait indefinitely for semaphores held by each other in a cycle, while starvation happens when low-priority processes never acquire a semaphore due to unfair scheduling.

Example:
Process P1P_1 holds SAS_A and waits for SBS_B, while P2P_2 holds SBS_B and waits for SAS_A, creating a circular wait P1SBP2SAP1P_1 \to S_B \to P_2 \to S_A \to P_1.

Reason:
These issues arise from improper semaphore acquisition ordering or LIFO/FIFO policy failures, requiring careful design to ensure liveness properties alongside safety.

16
Easy
25
Medium
11
Hard

📝 All Deadlocks and Starvation in Semaphore MCQs

Q1. What is a deadlock in the context of semaphores?

A.A situation where a process terminates unexpectedly.
B.A situation where two or more processes are waiting indefinitely for an event that can be caused only by one of the waiting processes. ✅
C.A situation where a process is blocked due to busy waiting.
D.A situation where the semaphore value becomes negative.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A deadlock occurs when two or more processes are each waiting for an event that can only be caused by another waiting process. This creates a circular dependency where no process can proceed, as each is waiting for a resource held by another.

Q2. What is the event that processes in a deadlock are waiting for?

A.The execution of a wait() operation.
B.The execution of a signal() operation. ✅
C.The termination of a process.
D.The allocation of memory.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: In semaphore-based deadlocks, processes are waiting for a signal() operation to be executed. This operation would release a resource or semaphore, allowing a waiting process to proceed. However, the process that would execute the signal() is itself waiting for another signal().

Q3. What happens when two processes are deadlocked in a semaphore system?

A.Both processes continue to execute.
B.Both processes wait indefinitely. ✅
C.One process terminates.
D.The semaphore values are reset.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: In a deadlock, both processes wait indefinitely. Neither process can proceed because each is waiting for the other to release a resource. This results in a complete standstill where no progress is made by the deadlocked processes.

Q4. In the classic deadlock example, what are the two semaphores initialized to?

A.0
B.1 ✅
C.-1
D.2
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: In the classic deadlock example, both semaphores S and Q are initialized to 1. This initial value represents that the resources are available. The deadlock occurs when the processes acquire the semaphores in different orders, leading to a circular wait.

Q5. In the deadlock example with processes P0 and P1, what sequence of operations leads to deadlock?

A.P0 executes wait(Q), P1 executes wait(S), P0 executes wait(S), P1 executes wait(Q).
B.P0 executes wait(S), P1 executes wait(Q), P0 executes wait(Q), P1 executes wait(S). ✅
C.P0 executes signal(S), P1 executes signal(Q).
D.P0 executes wait(S), P1 executes signal(Q).
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Deadlock occurs when P0 executes wait(S) and then wait(Q), while P1 executes wait(Q) and then wait(S). This creates a circular dependency: P0 holds S and waits for Q, while P1 holds Q and waits for S. Neither can proceed because each is waiting for the resource held by the other.

Q6. What is the state of a set of processes in a deadlock?

A.Every process is in the ready state.
B.Every process is waiting for an event that can be caused only by another process in the set. ✅
C.Every process is in the running state.
D.Every process has terminated.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A set of processes is in a deadlocked state when every process in the set is waiting for an event that can only be caused by another process in the set. This circular dependency prevents any process from proceeding, resulting in a deadlock.

Q7. What type of events primarily cause deadlocks in the context of semaphores?

A.Interrupt events.
B.Resource acquisition and release events. ✅
C.I/O completion events.
D.Timer events.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The events mainly concerned with deadlocks are resource acquisition and release. In the semaphore context, these correspond to the wait() and signal() operations on semaphores. Deadlocks occur when processes acquire resources in an order that leads to circular waiting.

Q8. What is starvation in the context of semaphores?

A.A situation where a process is terminated.
B.A situation where a process waits indefinitely for a semaphore. ✅
C.A situation where a process is running continuously.
D.A situation where a semaphore is always available.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Starvation, also known as indefinite blocking, occurs when a process waits indefinitely for a semaphore. Unlike deadlock, starvation does not necessarily involve circular waiting; it can occur when a process is perpetually bypassed by other processes due to unfair scheduling or queue management.

Q9. What queueing order can cause indefinite blocking or starvation?

A.FIFO (First-In-First-Out).
B.LIFO (Last-In-First-Out). ✅
C.Priority-based order.
D.Round-robin order.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: LIFO (Last-In-First-Out) removal order can cause starvation. If processes are removed from the semaphore's waiting list in LIFO order, a process that has been waiting for a long time may be perpetually bypassed by newer processes. This leads to indefinite blocking or starvation of older processes.

Q10. How can starvation be prevented in semaphore implementations?

A.By using LIFO removal order.
B.By using FIFO removal order. ✅
C.By using random removal order.
D.By not using a waiting list.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Starvation can be prevented by using FIFO (First-In-First-Out) removal order. This ensures that processes are awakened in the order they were blocked, guaranteeing that no process waits indefinitely. This provides bounded waiting and prevents starvation, ensuring fairness.

Q11. What is the relationship between deadlock and starvation?

A.They are the same condition.
B.Starvation is a subset of deadlock.
C.Deadlock is a subset of starvation.
D.They are different conditions, but both involve indefinite waiting. ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Deadlock and starvation are different conditions, but both involve indefinite waiting. Deadlock involves circular waiting among processes, while starvation involves a process being indefinitely bypassed by others. However, both can occur in semaphore systems and both result in a process not making progress.

Q12. In the classic deadlock example, why does P0 wait on Q?

A.Because P0 holds S and Q is held by P1. ✅
B.Because P0 has terminated.
C.Because Q has been signaled.
D.Because P0 does not need Q.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: P0 waits on Q because Q is held by P1. P0 holds S (acquired via wait(S)) and is trying to acquire Q. However, P1 holds Q (acquired via wait(Q)) and is trying to acquire S. This creates the circular dependency that causes the deadlock.

Q13. In the classic deadlock example, why does P1 wait on S?

A.Because P1 holds Q and S is held by P0. ✅
B.Because P1 has terminated.
C.Because S has been signaled.
D.Because P1 does not need S.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: P1 waits on S because S is held by P0. P1 holds Q and is trying to acquire S. However, P0 holds S and is trying to acquire Q. This mutual dependency results in both processes waiting indefinitely, causing deadlock.

Q14. What is the circular dependency in the classic deadlock example?

A.P0 holds S and waits for Q; P1 holds Q and waits for S. ✅
B.P0 holds Q and waits for S; P1 holds S and waits for Q.
C.P0 holds S and Q; P1 holds nothing.
D.P0 holds nothing; P1 holds S and Q.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The circular dependency is: P0 holds S and waits for Q, while P1 holds Q and waits for S. This forms a cycle where each process holds a resource that the other needs, and each is waiting for the resource held by the other. This cycle is the essence of a deadlock.

Q15. What is the effect of deadlock on the system?

A.The system becomes faster.
B.The system makes no progress with respect to the deadlocked processes. ✅
C.The system terminates all processes.
D.The system allocates more resources.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Deadlock causes the system to make no progress with respect to the deadlocked processes. These processes are stuck waiting indefinitely, and the resources they hold are not released. This can lead to resource wastage and system degradation.

Q16. What operation must be executed to break a deadlock?

A.wait()
B.signal() ✅
C.block()
D.wakeup()
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: To break a deadlock, a signal() operation must be executed. However, in a deadlock, the process that would execute the signal() is itself waiting. Therefore, external intervention is typically required, such as preempting resources or terminating one of the processes.

Q17. What is indefinite blocking in the context of semaphores?

A.A process is blocked for a short time.
B.A process is blocked indefinitely, never making progress. ✅
C.A process is blocked but can continue later.
D.A process is not blocked at all.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Indefinite blocking, also known as starvation, occurs when a process is blocked indefinitely and never makes progress. This is a serious problem in process synchronization that can occur due to unfair scheduling or queue management, such as LIFO removal order.

Q18. What is the key difference between deadlock and starvation?

A.Deadlock involves circular waiting; starvation does not. ✅
B.Starvation involves circular waiting; deadlock does not.
C.They are exactly the same.
D.Deadlock is more severe than starvation.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The key difference is that deadlock involves circular waiting among processes, where each process waits for a resource held by another. Starvation does not involve circular waiting; it occurs when a process is perpetually bypassed by other processes, often due to unfair queuing strategies like LIFO.

Q19. What can be done to prevent starvation in semaphore queues?

A.Use LIFO order.
B.Use FIFO order. ✅
C.Use random order.
D.Use priority order.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Using FIFO (First-In-First-Out) order in the semaphore queue prevents starvation. This ensures that processes are awakened in the order they were blocked, providing fairness and bounded waiting. A process will eventually be awakened, preventing indefinite blocking.

Q20. What is the consequence of using LIFO order in semaphore queues?

A.It prevents starvation.
B.It can cause starvation. ✅
C.It prevents deadlock.
D.It has no effect on processes.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Using LIFO (Last-In-First-Out) order in semaphore queues can cause starvation. Newer processes are awakened first, while older processes may be perpetually bypassed. This leads to indefinite blocking for older processes, which is a form of starvation.

Q21. What is the role of the signal() operation in preventing deadlocks?

A.It prevents deadlocks by releasing resources.
B.It can cause deadlocks if not executed properly. ✅
C.It has no role in deadlock prevention.
D.It prevents starvation.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The signal() operation releases resources and can help prevent deadlocks if used correctly. However, if a process fails to execute signal() or if the execution order leads to circular waiting, deadlocks can occur. Proper use of signal() is critical for deadlock prevention.

Q22. What is a necessary condition for deadlock in a semaphore system?

A.A process must be in the ready state.
B.There must be circular waiting for resources. ✅
C.The semaphore must be initialized to 0.
D.There must be no waiting processes.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A necessary condition for deadlock is circular waiting. This occurs when each process holds a resource that the next process needs, creating a cycle. Without circular waiting, deadlock cannot occur. Other conditions like mutual exclusion and hold and wait are also necessary.

Q23. What is the typical outcome of a deadlock scenario?

A.All processes complete successfully.
B.Processes are terminated automatically.
C.Processes wait indefinitely for resources. ✅
D.Resources are automatically released.
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: In a deadlock scenario, processes wait indefinitely for resources. Neither process can proceed because each is waiting for a resource held by the other. The deadlock persists until external intervention breaks the cycle.

Q24. What is the difference between deadlock and livelock?

A.Deadlock involves processes waiting indefinitely; livelock involves processes continuously changing state but not progressing. ✅
B.Deadlock involves continuous state changes; livelock involves indefinite waiting.
C.They are the same.
D.Deadlock is a subset of livelock.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Deadlock involves processes waiting indefinitely for resources. Livelock involves processes continuously changing their state (e.g., releasing and re-acquiring resources) but still not making progress. In livelock, processes are not blocked but are unable to complete their tasks.

Q25. What is the classic deadlock scenario with P0 and P1 an example of?

A.A situation where both processes execute correctly.
B.A situation where both processes are deadlocked due to circular waiting. ✅
C.A situation where one process terminates.
D.A situation where resources are shared fairly.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The classic deadlock scenario with P0 and P1 is an example of circular waiting. P0 holds S and waits for Q, while P1 holds Q and waits for S. This creates a cycle, and both processes are deadlocked as neither can proceed.

Q26. What is the condition for a process to be in a deadlocked state?

A.The process is in the ready state.
B.The process is waiting for an event that can only be caused by another process in the deadlocked set. ✅
C.The process is running continuously.
D.The process has terminated.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A process is in a deadlocked state when it is waiting for an event that can only be caused by another process in the deadlocked set. This creates a circular dependency where each process is waiting for an event that cannot occur until the other processes proceed, which they cannot.

Q27. What is the key characteristic of a deadlocked set of processes?

A.Every process is waiting for resources held by other processes in the set. ✅
B.Every process is running.
C.Every process has terminated.
D.Every process is in the ready queue.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The key characteristic of a deadlocked set is that every process is waiting for resources held by other processes in the set. This creates a circular dependency where no process can proceed, resulting in a deadlock.

Q28. What is the event that deadlocked processes are typically waiting for?

A.The execution of a wait() operation.
B.The execution of a signal() operation. ✅
C.The termination of a process.
D.The allocation of memory.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Deadlocked processes are typically waiting for the execution of a signal() operation. This operation would release a resource or semaphore, allowing a waiting process to proceed. However, the process that would execute the signal() is itself waiting for another signal().

Q29. What is the role of the waiting queue in deadlock and starvation?

A.It prevents deadlock.
B.It can contribute to both deadlock and starvation if not managed properly. ✅
C.It prevents starvation.
D.It has no role.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The waiting queue can contribute to both deadlock and starvation. Deadlock can occur if the queue contains processes waiting for resources held by each other. Starvation can occur if the queue management (like LIFO) causes some processes to wait indefinitely.

Q30. What is the relationship between deadlock and resource allocation?

A.Deadlock occurs when resources are allocated in a circular manner. ✅
B.Deadlock occurs when resources are allocated fairly.
C.Deadlock occurs when resources are not needed.
D.Deadlock has no relationship to resource allocation.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Deadlock occurs when resources are allocated in a circular manner. Each process holds a resource and waits for another resource held by another process. This circular allocation of resources is a necessary condition for deadlock.

Q31. What can be done to avoid deadlock in semaphore systems?

A.Ensure that processes always acquire resources in the same order. ✅
B.Use LIFO order for waiting queues.
C.Allow processes to acquire resources in any order.
D.Do not use semaphores.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Deadlock can be avoided by ensuring that processes always acquire resources in the same order. For example, if all processes acquire S before Q, the circular dependency that leads to deadlock is prevented. This is a common approach to deadlock avoidance.

Q32. What is the primary cause of starvation in semaphore implementations?

A.Circular waiting.
B.Unfair queue management, such as LIFO. ✅
C.Semaphore initialization.
D.Signal() operations.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The primary cause of starvation in semaphore implementations is unfair queue management. For example, using LIFO (Last-In-First-Out) order can cause older processes to be perpetually bypassed by newer processes, leading to indefinite blocking or starvation.

Q33. How can starvation be distinguished from deadlock?

A.Starvation involves circular waiting; deadlock does not.
B.Deadlock involves circular waiting; starvation does not. ✅
C.They are indistinguishable.
D.Starvation is always temporary.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Starvation can be distinguished from deadlock because deadlock involves circular waiting, while starvation does not. In starvation, a process waits indefinitely because it is perpetually bypassed, not because of a circular dependency. Both result in a process not making progress.

Q34. What is the result of a deadlock on system resources?

A.Resources are released automatically.
B.Resources are held indefinitely, reducing availability. ✅
C.Resources are reallocated.
D.Resources are destroyed.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: In a deadlock, resources are held indefinitely by the deadlocked processes. This reduces the availability of these resources for other processes and can degrade system performance. The held resources are not released until the deadlock is resolved.

Q35. What is the result of starvation on a process?

A.The process continues to run normally.
B.The process makes no progress and waits indefinitely. ✅
C.The process terminates.
D.The process is moved to the ready state.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Starvation results in a process making no progress and waiting indefinitely. Unlike deadlock, the process is not waiting for a resource held by another process in a cycle; it is being perpetually bypassed by other processes due to unfair scheduling or queue management.

Q36. What is the significance of the event that causes a deadlock?

A.The event must be caused by a process outside the deadlocked set.
B.The event can only be caused by a process within the deadlocked set. ✅
C.The event is caused by the operating system.
D.The event is caused by a timer interrupt.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The event that causes a deadlock can only be caused by a process within the deadlocked set. This is what creates the circular dependency. If the event could be caused by an external process, the deadlock could be broken. The inability of the waiting processes to cause the event is the essence of deadlock.

Q37. What is the role of the wait() operation in deadlock?

A.It prevents deadlock.
B.It can lead to deadlock if not used carefully. ✅
C.It has no role in deadlock.
D.It resolves deadlock.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The wait() operation can lead to deadlock if not used carefully. If processes acquire resources using wait() in an order that leads to circular waiting, deadlock can occur. Proper ordering of wait() operations is essential for deadlock avoidance.

Q38. What is the role of the signal() operation in resolving deadlock?

A.It can resolve deadlock if executed by a waiting process.
B.It cannot resolve deadlock because the process that would execute it is waiting. ✅
C.It always resolves deadlock.
D.It has no role in resolving deadlock.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The signal() operation cannot resolve deadlock because the process that would execute it is waiting. In a deadlock, each process is waiting for a signal() that cannot be executed. Therefore, external intervention is required to break the deadlock.

Q39. What is the relationship between semaphore initialization and deadlock?

A.Semaphore initialization can contribute to deadlock if resources are not properly managed. ✅
B.Semaphore initialization prevents deadlock.
C.Semaphore initialization has no effect on deadlock.
D.Semaphore initialization always causes deadlock.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Semaphore initialization can contribute to deadlock. For example, if semaphores are initialized to values that allow circular waiting, deadlock can occur. Proper initialization and careful management of semaphore values can help prevent deadlock.

Q40. What is the primary goal of deadlock prevention in semaphore systems?

A.To eliminate all semaphores.
B.To ensure that processes never wait for resources.
C.To ensure that processes acquire resources in a way that avoids circular waiting. ✅
D.To ensure that processes always acquire resources in LIFO order.
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: The primary goal of deadlock prevention is to avoid circular waiting. This can be achieved by ensuring that processes always acquire resources in a consistent, global order. This prevents the circular dependency that is necessary for deadlock.

Q41. What is the effect of a deadlock on system performance?

A.It improves system performance.
B.It degrades system performance due to resource wastage. ✅
C.It has no effect on system performance.
D.It speeds up process execution.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Deadlock degrades system performance by causing resources to be held indefinitely. These resources cannot be used by other processes, leading to resource wastage and reduced system throughput. The deadlocked processes also consume system resources without making progress.

Q42. What is the difference between indefinite blocking and deadlock?

A.Indefinite blocking is always caused by circular waiting.
B.Deadlock is always caused by circular waiting; indefinite blocking can be caused by other factors. ✅
C.They are exactly the same.
D.Indefinite blocking is more severe than deadlock.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Deadlock is always caused by circular waiting. Indefinite blocking (starvation) can be caused by other factors, such as unfair queue management (e.g., LIFO). While both result in a process waiting indefinitely, the underlying causes are different.

Q43. What is the role of the CPU scheduler in starvation?

A.It can cause starvation by selecting processes unfairly. ✅
B.It prevents starvation.
C.It has no role in starvation.
D.It resolves starvation by terminating processes.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The CPU scheduler can cause starvation by selecting processes in an unfair manner. If a process is never selected by the scheduler, it can starve. Similarly, in semaphore queues, the removal order (e.g., LIFO) can cause starvation. The scheduler and queue management must be fair to prevent starvation.

Q44. What is the relationship between deadlock and resource holding?

A.Deadlock requires that processes hold resources while waiting for others. ✅
B.Deadlock does not involve resource holding.
C.Deadlock requires that resources are not held.
D.Deadlock is unrelated to resource holding.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Deadlock requires that processes hold resources while waiting for others. This is the 'hold and wait' condition. In a deadlock, each process holds at least one resource and is waiting for additional resources held by other processes.

Q45. What is the significance of the order of wait() operations in deadlock prevention?

A.The order of wait() operations is critical in preventing deadlock. ✅
B.The order of wait() operations has no effect on deadlock.
C.The order of wait() operations only affects starvation.
D.The order of wait() operations only affects performance.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The order of wait() operations is critical in preventing deadlock. If all processes acquire resources in the same order, circular waiting is avoided, and deadlock cannot occur. This is a simple and effective deadlock prevention strategy.

Q46. What is the classic example of deadlock with P0 and P1 intended to illustrate?

A.The importance of proper semaphore initialization.
B.The dangers of circular waiting in resource acquisition. ✅
C.The benefits of using FIFO queues.
D.The efficiency of semaphore operations.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The classic deadlock example with P0 and P1 is intended to illustrate the dangers of circular waiting in resource acquisition. It shows how processes can become deadlocked when they acquire resources in different orders, leading to a cycle of waiting.

Q47. What is the condition for a process to be starved?

A.The process holds a resource and waits for another.
B.The process is perpetually bypassed by other processes. ✅
C.The process is in a circular wait.
D.The process has terminated.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A process is starved when it is perpetually bypassed by other processes. This occurs when the process waits for a resource but is never granted access because other processes are continuously given priority. This leads to indefinite blocking and no progress for the starved process.

Q48. What is the common solution to both deadlock and starvation in semaphore systems?

A.Use FIFO queues and enforce a consistent resource acquisition order. ✅
B.Use LIFO queues and random resource acquisition.
C.Terminate all processes.
D.Ignore the problems.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Using FIFO queues prevents starvation by ensuring fairness. Enforcing a consistent resource acquisition order prevents deadlock by avoiding circular waiting. Both of these strategies help to prevent the problems of deadlock and starvation in semaphore systems.

Q49. What is the role of the operating system in handling deadlock and starvation?

A.The operating system must detect and resolve deadlocks and prevent starvation. ✅
B.The operating system ignores deadlock and starvation.
C.The operating system terminates all processes.
D.The operating system only handles deadlock, not starvation.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The operating system plays a crucial role in handling deadlock and starvation. It must implement mechanisms for deadlock detection, prevention, and recovery. It must also ensure fair scheduling and queue management to prevent starvation. These are key responsibilities of the operating system.

Q50. What is the result of failing to handle deadlock in a system?

A.The system continues to run normally.
B.The system becomes unresponsive for the deadlocked processes and resource waste increases. ✅
C.The system speeds up.
D.All processes are terminated.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Failing to handle deadlock results in the system becoming unresponsive for the deadlocked processes. Resources are held indefinitely, leading to resource waste and potential system degradation. This can affect other processes and overall system performance.

Q51. What is the difference between deadlock and starvation in terms of resource holding?

A.In deadlock, processes hold resources; in starvation, processes may not hold resources. ✅
B.In starvation, processes hold resources; in deadlock, processes do not hold resources.
C.They both involve holding resources.
D.They both involve releasing resources.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: In deadlock, processes typically hold resources while waiting for others. In starvation, a process may not hold resources; it is simply waiting for access to resources that are continuously granted to other processes. The key difference is that deadlock involves holding, while starvation involves waiting without holding.

Q52. What is the key takeaway from the classic deadlock example with P0 and P1?

A.Deadlock can occur when processes acquire resources in different orders. ✅
B.Deadlock is rare in semaphore systems.
C.Deadlock can only occur with two processes.
D.Deadlock is easily resolved by the system.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The key takeaway from the classic deadlock example is that deadlock can occur when processes acquire resources in different orders. This leads to circular waiting, where each process holds a resource needed by the other. The solution is to enforce a consistent order for resource acquisition.

🔗 Related Topics (MCQs)