Problems Flashcards

1
Q

Producer Consumer Problem

A

The producer is not allowed to enter data when the buffer is full and the consumer cannot remove data when the buffer is empty.
we make use of mutex to ensure exclusive access to the buffer, empty to try the number of empty slots and full to track the number of full slots.

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

Reader Writer Problem

A

Multiple readers can read the CS but only one single writer is allowed to write at a given point of time.
We make use of semaphores to ensure only one single writer is in the CS.

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

Dining Philosophers problem

A

5 people at the dining table, 6 chopsticks and every person needs two chopsticks to eat.
Solution using semaphores fail as it leads to deadlock.
Solutions:
-> allow only 4 philosophers and 5 chopsticks.
-> allow philosopher to pick chopsticks only if both of his adjacent chopsticks are free.
->all the odd philosopher pick left chopstick and even one’s pick the right one first.

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