Semaphores Flashcards

1
Q

Give the definition:
An object with an integer value that we can manipulate with 2 routines

A

Semaphore

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give the definition:
An object that consists of locks & conditional variables

A

Semaphore

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What 2 routines can be used to manipulate a semaphore?

A

wait & post

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What routine for manipulation of a semaphore is described below?
Decrements sem value by 1. Waits if value of sem is < 0

A

wait

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What routine for manipulation of a semaphore is described below?
Increments sem value by 1. Then wakes up a single waiter if one exists.

A

post

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

initialization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Give the definition:
Binary semaphore

A

Lock

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Does the semaphore variable below represent the producer or the consumer in the p/c problem?
sem_t empty;

A

producer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Does the semaphore variable below represent the producer or the consumer in the p/c problem?
sem_t full;

A

consumer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What value is the sem_t value initialized to for the producer value, empty, in the p/c problem?

A

MAX

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What value is the sem_t value initialized to for the consumer value, full, in the p/c problem?

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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?

A

Deadlock state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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.

A

Deadlock state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which condition for a deadlock state is described below?
Threads claim exclusive control of resources that require e.g. a thread grabs a lock

A

Mutual exclusion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which condition for a deadlock state is described below?
Threads hold resources allocated to them while waiting for additional resources

A

Hold-and-wait

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which condition for a deadlock state is described below?
Resources cannot be forcibly removed from threads that are holding them

A

No preemption

17
Q

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.

A

Circular wait