1/9
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?
An object with an integer value manipulated by wait and post
What does sem_wait() do?
Decrements the value; if negative, the thread waits (sleeps)
What does sem_post() do?
Increments the value; if threads are waiting, wakes one
To use a semaphore as a Lock (mutex), what value should it be initialized to?
1
To use a semaphore for Ordering (e.g., parent waits for child), what value should it be initialized to?
0
How many semaphores are typically used to solve the Bounded Buffer problem?
3 (mutex, empty, full)
In the Producer/Consumer solution, where should the mutex be acquired?
Inside the empty/full wait calls (around the critical section only)
What is the goal of a Reader-Writer lock?
To allow multiple concurrent readers but only a single writer
In the Dining Philosophers problem, what causes deadlock?
Every philosopher grabbing the fork to their left simultaneously
Can semaphores be built using locks and condition variables?
Yes, easily