1/7
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is a semaphore in operating systems?
A semaphore is an integer variable used to synchronize processes by controlling access to shared resources.It can be either counting or binary, allowing for signaling between processes to prevent race conditions.
What does P(S) do?
It decrements S. If S ≤ 0, the calling process is blocked until S becomes positive
What does V(S) do?
it increments S and if there is a blocked processes, wake one up.
Why must P(S) and V(S) be executed atomically?
To avoid race conditions
What happens if multiple processes call P(S) while S ≤ 0?
The processes are blocked until a ‘v(s)‘ operation is called
What happens when V(S) is called while processes are waiting?
only one blocked process becomes unlocked and the others remains blocked
What happens if V(S) is called before P(S)?
S is gonna be incremented and When P(S) is called it will not block
What if the semaphore is initialized to S = 5?
up to 5 processes can enter the cs