🎓 BookMCQ
← Back to 5. Process Synchronization

📝 Semaphore Implementation in Process Synchronization (55 MCQs)

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

What is Semaphore Implementation in Process Synchronization?

Definition:
Semaphore implementation uses a queue of blocked processes and atomic hardware instructions to manage the semaphore value SS and prevent busy-waiting during wait operations.

Example:
When wait(S)wait(S) finds S0S \leq 0, the process is added to a FIFO queue QQ and suspended, resuming only when another process calls signal(S)signal(S).

Reason:
Queue-based implementation transforms spinlocks into blocking synchronization, preserving CPU cycles for useful work instead of wasting them in tight loops checking SS.

22
Easy
23
Medium
10
Hard

📝 All Semaphore Implementation in Process Synchronization MCQs

Q1. What is the main problem with the busy-waiting implementation of semaphores?

A.It causes deadlocks.
B.It wastes CPU cycles. ✅
C.It does not guarantee mutual exclusion.
D.It is difficult to implement.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Busy waiting wastes CPU cycles because a process continuously loops while waiting for the semaphore. This is inefficient in a multiprogramming system where the CPU could be used by other processes. The blocking implementation overcomes this problem.

Q2. How does the blocking implementation of semaphores overcome busy waiting?

A.By using a spinlock.
B.By allowing the process to continue execution.
C.By blocking the process and placing it in a waiting queue. ✅
D.By increasing the semaphore value.
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: In the blocking implementation, a process that cannot acquire the semaphore is blocked and placed in a waiting queue associated with the semaphore. This frees the CPU to execute other processes, eliminating the inefficiency of busy waiting.

Q3. What is the state of a process that is blocked on a semaphore?

A.Ready state.
B.Running state.
C.Waiting state. ✅
D.Terminated state.
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: A process that is blocked on a semaphore is switched to the waiting state. It remains in this state until it is awakened by a `signal()` operation from another process. This is a fundamental concept in process synchronization.

Q4. Which operation restarts a process that is blocked on a semaphore?

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

📖 Explanation: The `wakeup()` operation restarts a blocked process by changing its state from waiting to ready. This operation is typically called from within the `signal()` implementation when a process is removed from the semaphore's waiting queue.

Q5. What does the `block()` operation do?

A.It wakes up a process.
B.It suspends the process that invokes it. ✅
C.It increments the semaphore value.
D.It decrements the semaphore value.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The `block()` operation suspends the process that invokes it. This operation is called by the `wait()` implementation when a process must wait on a semaphore. The process is placed in the waiting state and control is transferred to the CPU scheduler.

Q6. What does the `wakeup(P)` operation do?

A.It suspends process P.
B.It resumes the execution of a blocked process P. ✅
C.It terminates process P.
D.It creates a new process P.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The `wakeup(P)` operation resumes the execution of a blocked process P. It changes the process's state from waiting to ready and places it in the ready queue. This operation is called from the `signal()` implementation to restart a waiting process.

Q7. What is the structure of a semaphore in the blocking implementation?

A.An integer value and a list of processes. ✅
B.An integer value and a boolean flag.
C.A boolean flag and a list of processes.
D.A counter and a mutex lock.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: In the blocking implementation, a semaphore is defined as a structure containing an integer `value` and a `list` of processes that are waiting on the semaphore. This structure allows the semaphore to track both the resource count and the waiting processes.

Q8. What does the `value` field in a semaphore structure represent?

A.The number of processes in the system.
B.The number of available resources or waiting processes. ✅
C.The priority of the semaphore.
D.The time since initialization.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The `value` field in a semaphore structure represents either the number of available resources (when positive) or the number of waiting processes (when negative). This dual interpretation is a key feature of the blocking semaphore implementation.

Q9. What does the `list` field in a semaphore structure contain?

A.A list of all processes in the system.
B.A list of processes waiting on the semaphore. ✅
C.A list of processes in the ready queue.
D.A list of terminated processes.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The `list` field in a semaphore structure contains the list of processes that are currently waiting on that semaphore. When a process is blocked, it is added to this list. When a process is awakened, it is removed from this list.

Q10. What is the effect of `S->value--` in the modified `wait()` implementation?

A.It increments the semaphore value.
B.It decrements the semaphore value. ✅
C.It sets the semaphore value to 0.
D.It resets the semaphore value.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The `S->value--` operation decrements the semaphore value by 1. This is done regardless of whether the semaphore is positive or negative. This is the first step in the modified `wait()` implementation, which then checks if the value is negative to determine if the process should block.

Q11. What is the effect of `S->value++` in the modified `signal()` implementation?

A.It increments the semaphore value. ✅
B.It decrements the semaphore value.
C.It sets the semaphore value to 0.
D.It resets the semaphore value.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The `S->value++` operation increments the semaphore value by 1. This is the first step in the modified `signal()` implementation. After incrementing, the implementation checks if the value is less than or equal to 0 to determine if a waiting process should be awakened.

Q12. In the modified `wait()` implementation, when does a process block?

A.When `S->value` is positive.
B.When `S->value` is zero.
C.When `S->value` is negative after decrementing. ✅
D.When `S->value` is zero after decrementing.
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: In the modified `wait()` implementation, a process blocks when `S->value` becomes negative after the decrement. This indicates that the semaphore was 0 or negative before the operation, meaning no resources are available. The process is then added to the semaphore's waiting list.

Q13. In the modified `signal()` implementation, when is a process awakened?

A.When `S->value` is positive.
B.When `S->value` is zero.
C.When `S->value` is less than or equal to zero after incrementing. ✅
D.When `S->value` is greater than zero.
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: In the modified `signal()` implementation, a process is awakened when `S->value` is less than or equal to zero after the increment. This indicates that there was at least one process waiting on the semaphore before the signal operation. A process is removed from the waiting list and awakened.

Q14. What does a negative semaphore value indicate in the blocking implementation?

A.An error has occurred.
B.The number of available resources.
C.The number of processes waiting on the semaphore. ✅
D.The semaphore is not initialized.
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A negative semaphore value indicates the number of processes waiting on the semaphore. For example, a value of -3 means that 3 processes are blocked and waiting for the semaphore to be signaled. This is a key difference from the busy-waiting implementation where values are never negative.

Q15. What is the magnitude of a negative semaphore value equal to?

A.The number of available resources.
B.The number of processes waiting on the semaphore. ✅
C.The priority of the semaphore.
D.The number of processes in the system.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The magnitude of a negative semaphore value represents the number of processes waiting on that semaphore. For instance, if the semaphore value is -5, five processes are currently blocked and waiting for a `signal()` operation on that semaphore.

Q16. How can the list of waiting processes in a semaphore be implemented?

A.Using a fixed-size array.
B.Using a link field in each Process Control Block (PCB). ✅
C.Using a separate process table.
D.Using a hardware register.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The list of waiting processes can be implemented by using a link field in each Process Control Block (PCB). This allows each process to be linked to the next process in the waiting queue, providing an efficient way to manage the list of waiting processes.

Q17. What queueing strategy is commonly used to ensure bounded waiting in semaphore lists?

A.Priority queue.
B.FIFO queue. ✅
C.LIFO queue.
D.Round-robin queue.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A FIFO (First-In-First-Out) queue is commonly used to ensure bounded waiting. This guarantees that processes are awakened in the order they were blocked, preventing starvation and ensuring fairness. However, any queueing strategy can be used as long as it correctly implements the semaphore semantics.

Q18. What is the critical requirement for the `wait()` and `signal()` operations?

A.They must be executed in user mode.
B.They must be executed atomically. ✅
C.They must be called in pairs.
D.They must be called by the same process.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The `wait()` and `signal()` operations must be executed atomically. This ensures that no two processes can execute these operations on the same semaphore simultaneously, which would lead to race conditions and incorrect behavior. Atomicity is essential for the correct functioning of semaphores.

Q19. How can atomicity of semaphore operations be achieved in a single-processor environment?

A.By using a spinlock.
B.By disabling interrupts during the execution of `wait()` and `signal()`. ✅
C.By using a mutex lock.
D.By using a counting semaphore.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: In a single-processor environment, atomicity can be achieved by disabling interrupts during the execution of `wait()` and `signal()`. This prevents the current process from being interrupted, ensuring that the semaphore operations are executed without interference from other processes.

Q20. Why is disabling interrupts on every processor difficult in a multiprocessor environment?

A.Interrupts cannot be disabled on multiprocessor systems.
B.It requires coordinating with all processors and can seriously diminish performance. ✅
C.Only one processor can have interrupts disabled at a time.
D.It causes deadlocks.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Disabling interrupts on every processor in a multiprocessor system is difficult because it requires coordinating with all processors. This can be a complex task and can seriously diminish system performance due to the overhead of inter-processor communication and synchronization.

Q21. What alternative techniques are used in SMP systems to ensure atomicity of semaphore operations?

A.Disabling interrupts only on the current processor.
B.Using compare and swap() or spinlocks. ✅
C.Using a single global lock.
D.Using hardware interrupts.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: In SMP systems, alternative locking techniques such as `compare and swap()` or spinlocks are used to ensure atomicity. These techniques are more efficient than disabling interrupts on all processors and provide the necessary atomicity for semaphore operations in multiprocessor environments.

Q22. Has the blocking implementation of semaphores completely eliminated busy waiting?

A.Yes, busy waiting is completely eliminated.
B.No, busy waiting is still present but limited to the critical sections of `wait()` and `signal()`. ✅
C.Busy waiting is eliminated only in multiprocessor systems.
D.Busy waiting is eliminated only in single-processor systems.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The blocking implementation has not completely eliminated busy waiting. Busy waiting is still present in the critical sections of the `wait()` and `signal()` operations, but these critical sections are very short (typically less than ten instructions). This makes busy waiting rare and short-lived, unlike the long busy waiting in application critical sections.

Q23. Where is busy waiting still present in the blocking semaphore implementation?

A.In the application's critical sections.
B.In the critical sections of the `wait()` and `signal()` operations. ✅
C.In the process scheduler.
D.In the interrupt handler.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Busy waiting is still present in the critical sections of the `wait()` and `signal()` operations themselves. These critical sections are short and properly coded, making the busy waiting rare and of short duration. This is a significant improvement over application-level busy waiting, which can be very inefficient.

Q24. Why is the busy waiting in the critical sections of `wait()` and `signal()` considered acceptable?

A.Because it consumes no CPU cycles.
B.Because the critical sections are short, typically no more than about ten instructions. ✅
C.Because it only occurs in single-processor systems.
D.Because it is impossible to avoid.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The busy waiting in the critical sections of `wait()` and `signal()` is considered acceptable because these critical sections are very short. They are typically only a few instructions long, meaning that any busy waiting is minimal and unlikely to significantly impact system performance.

Q25. What is the purpose of the `block()` operation in the semaphore implementation?

A.To wake up a process.
B.To suspend the current process and place it in the waiting queue. ✅
C.To increment the semaphore value.
D.To remove a process from the waiting queue.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The `block()` operation suspends the current process and places it in the waiting queue associated with the semaphore. This operation is invoked by the `wait()` implementation when a process must wait for the semaphore. It allows the CPU to be used by other processes.

Q26. What is the purpose of the `wakeup(P)` operation in the semaphore implementation?

A.To suspend process P.
B.To change process P from the waiting state to the ready state. ✅
C.To terminate process P.
D.To create a new process P.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The `wakeup(P)` operation changes process P from the waiting state to the ready state. This operation is invoked by the `signal()` implementation when a waiting process is to be awakened. The process is then placed in the ready queue and can be scheduled for execution.

Q27. What is the role of the CPU scheduler when a process is blocked on a semaphore?

A.It continues to run the blocked process.
B.It selects another process to execute. ✅
C.It terminates the blocked process.
D.It increments the semaphore value.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: When a process is blocked on a semaphore, control is transferred to the CPU scheduler. The scheduler selects another process to execute, ensuring the CPU is not idle. This is the key advantage of the blocking implementation over busy waiting.

Q28. What is the effect of the modified `wait()` operation on the semaphore value when a process blocks?

A.The value is incremented.
B.The value is decremented and becomes negative. ✅
C.The value remains unchanged.
D.The value is set to 0.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: In the modified `wait()` operation, the semaphore value is decremented first. If the process blocks, the value becomes negative. The magnitude of the negative value indicates the number of processes waiting on the semaphore. This is a key feature of the blocking implementation.

Q29. What is the effect of the modified `signal()` operation on the semaphore value when a process is awakened?

A.The value is incremented and becomes negative.
B.The value is incremented and becomes less negative. ✅
C.The value is decremented.
D.The value is set to 0.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: When a process is awakened in the modified `signal()` operation, the semaphore value is incremented. If there were waiting processes, the value becomes less negative. For example, if the value was -3 and one process is awakened, the value becomes -2. The value is still negative, indicating there are still waiting processes.

Q30. What is the relationship between the semaphore value and the number of waiting processes?

A.The number of waiting processes is equal to the semaphore value.
B.The number of waiting processes is equal to the magnitude of a negative semaphore value. ✅
C.The number of waiting processes is always 0.
D.The number of waiting processes is equal to the positive semaphore value.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The relationship is that the number of waiting processes is equal to the magnitude of a negative semaphore value. For example, if the semaphore value is -4, it means that 4 processes are currently waiting on that semaphore. This is a direct consequence of the implementation's order of operations.

Q31. What is the role of the Process Control Block (PCB) in the semaphore implementation?

A.To store the semaphore value.
B.To contain a link field for implementing the waiting list. ✅
C.To schedule the processes.
D.To handle interrupts.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The Process Control Block (PCB) contains a link field that can be used to implement the waiting list for semaphores. Each PCB can point to the next PCB in the waiting queue, allowing the operating system to maintain the list of processes waiting on a semaphore efficiently.

Q32. What does a semaphore contain in the blocking implementation?

A.Only an integer value.
B.Only a list of processes.
C.An integer value and a pointer to a list of PCBs. ✅
D.A mutex lock and a condition variable.
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: A semaphore in the blocking implementation contains an integer value and a pointer to a list of Process Control Blocks (PCBs). The integer value tracks the number of available resources or waiting processes, and the list tracks the processes that are waiting on the semaphore.

Q33. What is the purpose of the FIFO queue in semaphore implementation?

A.To ensure bounded waiting. ✅
B.To increase performance.
C.To prevent deadlocks.
D.To simplify the implementation.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: A FIFO queue is used to ensure bounded waiting for semaphores. By waking processes in the order they were blocked, the FIFO queue ensures that no process waits indefinitely, satisfying the bounded waiting requirement and preventing starvation.

Q34. What is the problem with busy waiting in application programs with long critical sections?

A.It is acceptable because critical sections are short.
B.It is extremely inefficient because it wastes CPU cycles for a long time. ✅
C.It causes deadlocks.
D.It is not a problem in modern systems.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Busy waiting in application programs with long critical sections is extremely inefficient. The process waiting for the lock consumes CPU cycles continuously for the duration of the critical section, which could be minutes or even hours. This is a huge waste of resources and degrades system performance.

Q35. How does the blocking implementation reduce the inefficiency of busy waiting?

A.By eliminating all busy waiting.
B.By moving busy waiting from application critical sections to the short critical sections of `wait()` and `signal()`. ✅
C.By using a spinlock.
D.By increasing the semaphore value.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The blocking implementation reduces inefficiency by moving busy waiting from the potentially long critical sections of application programs to the very short critical sections of the `wait()` and `signal()` operations. This makes busy waiting rare and brief, significantly improving system performance.

Q36. What is the maximum length of the critical sections in a properly coded `wait()` and `signal()` implementation?

A.About ten instructions. ✅
B.About one hundred instructions.
C.About one thousand instructions.
D.There is no limit.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: In a properly coded implementation, the critical sections of `wait()` and `signal()` are very short, typically no more than about ten instructions. This makes busy waiting in these sections negligible and ensures that the implementation is efficient.

Q37. What is the main challenge of implementing semaphores in a multiprocessor environment?

A.Atomicity of operations. ✅
B.Managing the semaphore value.
C.Creating the waiting list.
D.Initializing the semaphore.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The main challenge in multiprocessor environments is ensuring the atomicity of the `wait()` and `signal()` operations. Since multiple processors can execute concurrently, special care must be taken to prevent race conditions on the semaphore itself. This requires sophisticated locking techniques like spinlocks or `compare and swap()`.

Q38. What technique can be used to ensure atomicity of semaphore operations in a single-processor environment?

A.Disabling interrupts. ✅
B.Using a spinlock.
C.Using `compare and swap()`.
D.Using a mutex lock.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: In a single-processor environment, disabling interrupts is a simple and effective way to ensure atomicity. When interrupts are disabled, no other process can interrupt the current process, ensuring that the semaphore operations are executed without interference.

Q39. Why is disabling interrupts not feasible in a multiprocessor environment for semaphore implementation?

A.Interrupts cannot be disabled on multiprocessor systems.
B.It requires disabling interrupts on every processor, which is difficult and diminishes performance. ✅
C.It causes deadlocks.
D.It only works on single-core processors.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Disabling interrupts on every processor in a multiprocessor system is not feasible because it requires complex coordination with all processors. This coordination introduces significant overhead and can severely diminish system performance, making it unsuitable for frequent semaphore operations.

Q40. What is the purpose of the `list` in the semaphore structure?

A.To store the semaphore value.
B.To store the processes waiting on the semaphore. ✅
C.To store the processes in the ready queue.
D.To store the processes in the running state.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The `list` in the semaphore structure is used to store the processes that are waiting on the semaphore. When a process blocks on the semaphore, it is added to this list. When a process is awakened, it is removed from this list. This is a key component of the blocking implementation.

Q41. What is the state of a process after a `wakeup()` operation?

A.Waiting state.
B.Running state.
C.Ready state. ✅
D.Terminated state.
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: After a `wakeup()` operation, the process is in the ready state. The `wakeup()` operation changes the process's state from waiting to ready, indicating that the process is now eligible to be scheduled for execution.

Q42. What is the state of a process after a `block()` operation?

A.Ready state.
B.Running state.
C.Waiting state. ✅
D.Terminated state.
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: After a `block()` operation, the process is in the waiting state. The `block()` operation suspends the process and places it in the waiting queue associated with the semaphore, indicating that the process is waiting for a semaphore to be signaled.

Q43. What is the primary advantage of the blocking implementation over the busy-waiting implementation?

A.It is easier to implement.
B.It is more efficient because it does not waste CPU cycles while waiting. ✅
C.It requires less memory.
D.It works on all hardware.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The primary advantage of the blocking implementation is its efficiency. By blocking processes that are waiting for a semaphore, the CPU is freed to execute other processes. This is much more efficient than busy waiting, where a process consumes CPU cycles while doing no useful work.

Q44. What is the significance of moving busy waiting from application programs to the operating system's `wait()` and `signal()` operations?

A.It eliminates busy waiting entirely.
B.It makes busy waiting more efficient because operating system code is faster.
C.It limits busy waiting to very short critical sections, reducing its impact on performance. ✅
D.It has no significance.
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: The significance is that it limits busy waiting to very short critical sections (typically a few instructions). In application programs, critical sections can be long, leading to significant wasted CPU cycles. By moving busy waiting to the operating system, the inefficiency is greatly reduced.

Q45. What is the relationship between the semaphore value and the number of waiting processes in the blocking implementation?

A.The semaphore value is always positive.
B.The semaphore value is always negative.
C.A positive value indicates available resources, while a negative value's magnitude indicates waiting processes. ✅
D.The semaphore value is always 0.
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: In the blocking implementation, a positive semaphore value indicates the number of available resources. A negative value indicates that processes are waiting, and the magnitude of the negative value indicates the number of waiting processes. A value of 0 indicates no available resources and no waiting processes.

Q46. What happens when a process is added to a semaphore's waiting list?

A.The process continues to execute.
B.The process is terminated.
C.The process is blocked and enters the waiting state. ✅
D.The process is moved to the ready state.
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: When a process is added to a semaphore's waiting list, it is blocked and enters the waiting state. The process will remain in this state until it is removed from the waiting list and awakened by a `wakeup()` operation.

Q47. What happens when a process is removed from a semaphore's waiting list?

A.The process is terminated.
B.The process is awakened and enters the ready state. ✅
C.The process is blocked.
D.The process continues to wait.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: When a process is removed from a semaphore's waiting list, it is awakened and enters the ready state. The `wakeup()` operation is responsible for this state transition, allowing the process to be scheduled for execution.

Q48. What is the purpose of the atomicity requirement for semaphore operations?

A.To ensure the semaphore operations are fast.
B.To prevent race conditions on the semaphore itself. ✅
C.To ensure the semaphore operations are always successful.
D.To prevent deadlocks.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The atomicity requirement ensures that `wait()` and `signal()` operations on the same semaphore are executed without interruption. This prevents race conditions where two processes might simultaneously modify the semaphore value or list, leading to incorrect behavior and synchronization errors.

Q49. What is the main drawback of using spinlocks to implement semaphores in multiprocessor systems?

A.They are difficult to implement.
B.They still involve busy waiting, but only in the critical sections of semaphore operations. ✅
C.They do not work in multiprocessor systems.
D.They are slower than disabling interrupts.
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The main drawback of spinlocks is that they still involve busy waiting. While the busy waiting is limited to the critical sections of the semaphore operations, it is still a form of busy waiting. However, this busy waiting is short and considered acceptable compared to the long busy waiting in application critical sections.

Q50. What is the purpose of the `list` pointer in the semaphore structure?

A.To point to the semaphore's value.
B.To point to the first process in the waiting list. ✅
C.To point to the CPU scheduler.
D.To point to the memory management unit.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The `list` pointer in the semaphore structure points to the first process in the waiting list. This allows the operating system to access the list of processes waiting on the semaphore, enabling it to add new processes when they block and remove processes when they are awakened.

Q51. What does the `signal()` operation do when the semaphore value becomes less than or equal to zero after incrementing?

A.It blocks the current process.
B.It removes a process from the semaphore's waiting list and wakes it up. ✅
C.It terminates a process.
D.It does nothing.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When the semaphore value becomes less than or equal to zero after incrementing, the `signal()` operation removes a process from the semaphore's waiting list and wakes it up. This ensures that a waiting process is awakened when a resource becomes available.

Q52. What does the `wait()` operation do when the semaphore value becomes negative after decrementing?

A.It continues execution.
B.It blocks the current process and adds it to the semaphore's waiting list. ✅
C.It wakes up a process.
D.It terminates the current process.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When the semaphore value becomes negative after decrementing, the `wait()` operation blocks the current process and adds it to the semaphore's waiting list. This indicates that no resources are available, and the process must wait until a resource is released.

Q53. What is the key difference between the classical and modified semaphore implementations?

A.The classical implementation uses blocking, while the modified implementation uses busy waiting.
B.The classical implementation never has negative values, while the modified implementation can have negative values. ✅
C.The classical implementation is faster.
D.The modified implementation is easier to implement.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The key difference is that the classical implementation (with busy waiting) never has negative semaphore values, while the modified implementation (with blocking) can have negative values. The magnitude of the negative value indicates the number of waiting processes in the modified implementation.

Q54. What is the effect of the modified `signal()` operation on the semaphore value?

A.It decrements the value by 1.
B.It increments the value by 1. ✅
C.It sets the value to 0.
D.It sets the value to the number of waiting processes.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The modified `signal()` operation increments the semaphore value by 1. This is the first step of the operation. If the value becomes less than or equal to 0, a waiting process is awakened. This increment represents the release of a resource.

Q55. What is the effect of the modified `wait()` operation on the semaphore value?

A.It increments the value by 1.
B.It decrements the value by 1. ✅
C.It sets the value to 0.
D.It sets the value to the number of available resources.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The modified `wait()` operation decrements the semaphore value by 1. This is the first step of the operation. If the value becomes negative, the process blocks. This decrement represents the acquisition of a resource.

🔗 Related Topics (MCQs)