0
0
Operating Systemsknowledge~5 mins

Semaphores (counting and binary) in Operating Systems - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AAny non-negative integer
BOnly 0 or 1
COnly positive integers
DOnly negative integers
Which semaphore type acts like a simple lock?
AMutex semaphore
BCounting semaphore
CBinary semaphore
DSignal semaphore
What operation decreases the semaphore value when a process wants to enter a critical section?
ASignal
BRelease
CLock
DWait
What does the 'signal' operation do in semaphore usage?
ADecreases semaphore value
BIncreases semaphore value
CBlocks the process
DTerminates the process
Why are semaphores used in operating systems?
ATo prevent race conditions and manage resource sharing
BTo encrypt data
CTo store data permanently
DTo speed up CPU processing
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.