Semaphores Flashcards
Give the definition:
An object with an integer value that we can manipulate with 2 routines
Semaphore
Give the definition:
An object that consists of locks & conditional variables
Semaphore
What 2 routines can be used to manipulate a semaphore?
wait & post
What routine for manipulation of a semaphore is described below?
Decrements sem value by 1. Waits if value of sem is < 0
wait
What routine for manipulation of a semaphore is described below?
Increments sem value by 1. Then wakes up a single waiter if one exists.
post
What routine for manipulation of a semaphore is described below?
Determines a semaphores behavior - the value of the semaphore when negative = number of waiting threads
initialization
Give the definition:
Binary semaphore
Lock
Does the semaphore variable below represent the producer or the consumer in the p/c problem?
sem_t empty;
producer
Does the semaphore variable below represent the producer or the consumer in the p/c problem?
sem_t full;
consumer
What value is the sem_t value initialized to for the producer value, empty, in the p/c problem?
MAX
What value is the sem_t value initialized to for the consumer value, full, in the p/c problem?
0
When using semaphores in the p/c problem, the mutex locks are put just around the critical section to ensure that what state doesn’t occur?
Deadlock state
Give the definition:
A set of threads are said to be in this state when every thread in the set is waiting for an event that can be caused only by another thread in the set.
Deadlock state
Which condition for a deadlock state is described below?
Threads claim exclusive control of resources that require e.g. a thread grabs a lock
Mutual exclusion
Which condition for a deadlock state is described below?
Threads hold resources allocated to them while waiting for additional resources
Hold-and-wait
Which condition for a deadlock state is described below?
Resources cannot be forcibly removed from threads that are holding them
No preemption
Which condition for a deadlock state is described below?
There exists a circular chain of threads such that each holds one/more resources that are being requested by the next thread in the chain.
Circular wait