Recall & Review
beginner
What is a semaphore in operating systems?
A semaphore is a tool used to control access to shared resources by multiple processes to avoid conflicts and ensure safe execution.
Click to reveal answer
beginner
What is the difference between a counting semaphore and a binary semaphore?
A counting semaphore can have any non-negative integer value and controls access to multiple instances of a resource. A binary semaphore only has two values (0 or 1) and controls access to a single resource, acting like a simple lock.
Click to reveal answer
intermediate
How does a process use a semaphore to enter a critical section?
The process performs a 'wait' operation on the semaphore. If the semaphore value is positive, it decreases the value and enters the critical section. If zero, the process waits until the semaphore is available.
Click to reveal answer
intermediate
What happens when a process finishes using a resource controlled by a semaphore?
The process performs a 'signal' operation, which increases the semaphore value and may wake up a waiting process to allow it to enter the critical section.
Click to reveal answer
beginner
Why are semaphores important in operating systems?
Semaphores help prevent race conditions and ensure that multiple processes can safely share resources without interfering with each other.
Click to reveal answer
What value range does a counting semaphore hold?
✗ Incorrect
Counting semaphores can hold any non-negative integer to represent multiple available resources.
Which semaphore type acts like a simple lock?
✗ Incorrect
Binary semaphores have only two values (0 or 1) and act like locks to control access to a single resource.
What operation decreases the semaphore value when a process wants to enter a critical section?
✗ Incorrect
The 'wait' operation decreases the semaphore value if it is positive, allowing the process to enter.
What does the 'signal' operation do in semaphore usage?
✗ Incorrect
The 'signal' operation increases the semaphore value and may wake waiting processes.
Why are semaphores used in operating systems?
✗ Incorrect
Semaphores help coordinate processes to avoid conflicts when sharing resources.
Explain how counting and binary semaphores differ and give a real-life example for each.
Think about how many resources each semaphore controls.
You got /4 concepts.
Describe the sequence of operations a process performs when using a semaphore to access a shared resource safely.
Focus on wait and signal steps.
You got /5 concepts.