Synchronization Flashcards

1
Q

What is the Bounded Buffer Problem

A

Assume
• there are n buffers, each capable of holding one
item
• a producer produces an element and, if there is
an empty buffer, adds the item to a buffer
• if there is a full buffer, the consumer removes
an item from the buffer
• mutex is initialised to 1
• full is initialised to 0 (no buffer has a value)
• empty is initialised to n (all n buffers are empty)

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

What is the Reader-Writers Problem

A

Assume a single data variable is shared among concurrent processes
•While a process is writing to the shared data, no other process may access the data,
whether it is reading or writing
•Multiple reader processes may access the database simultaneously
•No reader may be kept waiting unless a writer has exclusive access; this may result in the starvation of writers
•Semaphore wrt (initialised to 1) is used to ensure no writer is allowed to access the shared data if any other process is currently
accessing the data
•Semaphore mutex (initialised to 1) is used to provide exclusive access to the shared variable readcount

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

What is the Dining Philosophers Problem

A

Assume there are:
• 5 philosophers around a table
• with a single bowl of rice in the middle and
• 5 chopsticks, 1 between each pair of philosophers
• A philosopher may only pick up the chopsticks on its left and right

A philosopher can be
•thinking - has no chopsticks and does not try to pick up chopsticks
•hungry - needs two chopsticks and therefore
tries to pick up the chopsticks on its left and right respectively
•eating - has two chopsticks and is eating; when finished it puts both down and starts thinking again

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

What is the difference between a binary semaphore and a counting semaphore?

A

A binary semaphore moves between the state 0 and 1 allowing only a single concurrent access to the guarded resource whereas a counting semaphore may allow multiple counter increases and decreases based on a predefined limit X, and X processes can then access the resource guarded by the semaphore.

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