Chapter 31: Semaphores

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:21 AM on 3/5/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards

What is a semaphore?

An object with an integer value manipulated by wait and post

2
New cards

What does sem_wait() do?

Decrements the value; if negative, the thread waits (sleeps)

3
New cards

What does sem_post() do?

Increments the value; if threads are waiting, wakes one

4
New cards

To use a semaphore as a Lock (mutex), what value should it be initialized to?

1

5
New cards

To use a semaphore for Ordering (e.g., parent waits for child), what value should it be initialized to?

0

6
New cards

How many semaphores are typically used to solve the Bounded Buffer problem?

3 (mutex, empty, full)

7
New cards

In the Producer/Consumer solution, where should the mutex be acquired?

Inside the empty/full wait calls (around the critical section only)

8
New cards

What is the goal of a Reader-Writer lock?

To allow multiple concurrent readers but only a single writer

9
New cards

In the Dining Philosophers problem, what causes deadlock?

Every philosopher grabbing the fork to their left simultaneously

10
New cards

Can semaphores be built using locks and condition variables?

Yes, easily