To Understand Process Synchronization

Post Test

1. What happens if a producer tries to add an item to a full buffer when using semaphores in Producer-Consumer problem?

a) The item is added, and the buffer overflows
b) The producer is blocked until space is available
c) The item is discarded
d) The producer switches to a consumer

2. In the Producer-Consumer problem, which semaphore should a consumer wait on before consuming an item?

a) Empty
b) Mutex
c) Full
d) Buffer

3. Which of the following is a potential drawback of using a hierarchy of chopstick access in the Dining Philosophers problem?

a) Increased complexity in managing the hierarchy.
b) Difficulty in ensuring fairness among philosophers.
c) Potential for deadlock if two philosophers with high priority access the same chopstick.
d) All of the above.

4. If the "mutex" semaphore is used to protect access to the buffer, what value should it be initialized to?

a) 0
b) N
c) 1
d) -1

5. What is the main purpose of implementing mutual exclusion in a solution to the Dining Philosophers problem?

a) To prevent philosophers from using both chopsticks at the same time.
b) To ensure that only one philosopher can access a chopstick at any given time.
c) To guarantee that each philosopher gets a fair share of food.
d) To prevent philosophers from getting stuck in a deadlock.