Operating System Questions and Answers Part-22

1. The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.
Process P0
while(true)
{
wait(S0);
print '0';
release(S1);
release(S2);
}
Process P1
wait(S1);
release(S0);
Process P2
wait(S2);
release(S0);
How many times will P0 print ‘0’?
a) At least twice
b) Exactly twice
c) Exactly thrice
d) Exactly once

Answer: a
Explanation: At least twice

2. Each process Pi, i = 0,1,2,3,……,9 is coded as follows.
repeat
P(mutex)
{Critical Section}
V(mutex)
forever
The code for P10 is identical except that it uses V(mutex) instead of P(mutex). What is the largest number of processes that can be inside the critical section at any moment (the mutex being initialized to 1)?
a) 1
b) 2
c) 3
d) none of the mentioned

Answer: c
Explanation: Any one of the 9 processes can get into critical section after executing P(mutex) which decrements the mutex value to 0. At this time P10 can enter critical section by incrementing the value to 1. Now any of the 9 processes can enter the critical section by again decrementing the mutex value to 0. None of the remaining processes can get into their critical sections.

3. Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes.
Process P1 :
while(true)
{
w1 = true;
while(w2 == true);
Critical section
w1 = false;
}
Remainder Section
Process P2 :
while(true)
{
w2 = true;
while(w1 == true);
Critical section
w2 = false;
}
Remainder Section
Here, w1 and w2 have shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?.
a) It does not ensure mutual exclusion
b) It does not ensure bounded waiting
c) It requires that processes enter the critical section in strict alternation
d) It does not prevent deadlocks but ensures mutual exclusion

Answer: d
Explanation: It does not prevent deadlocks but ensures mutual exclusion

4. The bounded buffer problem is also known as ____________
a) Readers – Writers problem
b) Dining – Philosophers problem
c) Producer – Consumer problem
d) none of the mentioned

Answer: c
Explanation: Producer – Consumer problem

5. In the bounded buffer problem, there are the empty and full semaphores that ___________
a) count the number of empty and full buffers
b) count the number of empty and full memory spaces
c) count the number of empty and full queues
d) none of the mentioned

Answer: a
Explanation: In the bounded buffer problem, there are the empty and full semaphores that count the number of empty and full buffers

6. In the bounded buffer problem ____________
a) there is only one buffer
b) there are n buffers ( n being greater than one but finite)
c) there are infinite buffers
d) the buffer size is bounded

Answer: b
Explanation: there are n buffers ( n being greater than one but finite)

7. To ensure difficulties do not arise in the readers – writers problem _______ are given exclusive access to the shared object.
a) readers
b) writers
c) readers and writers
d) none of the mentioned

Answer: b
Explanation: writers

8. The dining – philosophers problem will occur in case of ____________
a) 5 philosophers and 5 chopsticks
b) 4 philosophers and 5 chopsticks
c) 3 philosophers and 5 chopsticks
d) 6 philosophers and 5 chopsticks

Answer: a
Explanation: The dining – philosophers problem will occur in case of 5 philosophers and 5 chopsticks

9. A deadlock free solution to the dining philosophers problem ____________
a) necessarily eliminates the possibility of starvation
b) does not necessarily eliminate the possibility of starvation
c) eliminates any possibility of any kind of problem further
d) none of the mentioned

Answer: b
Explanation: A deadlock free solution to the dining philosophers problem does not necessarily eliminate the possibility of starvation

10. All processes share a semaphore variable mutex, initialized to 1. Each process must execute wait(mutex) before entering the critical section and signal(mutex) afterward.
Suppose a process executes in the following manner.
signal(mutex);
.....
critical section
.....
wait(mutex);
In this situation :
a) a deadlock will occur
b) processes will starve to enter critical section
c) several processes maybe executing in their critical section
d) all of the mentioned

Answer: c
Explanation: several processes maybe executing in their critical section