OS Tutorial 4 Ques
OS Tutorial 4 Ques
Id No: Name:
Ans: 4 processes
Ans: 4 processes
3. Ten processes share a critical section implemented by using a counting semaphore named
x initialized to 1. Nine of these processes use the code wait(x); {critical section} signal(x).
However, one process erroneously uses the code signal(x); {critical section} signal(x). What is
the maximum number of processes that can be in the critical section at the same time?
wait(x);
{critical section}
signal(x)
signal(x);
{critical section}
signal(x)
Ans: 3 processes
4. Consider the Readers/writers problem. Time for read or write operation takes 5 units.
Ignore the time involved in execution of the rest of the instructions for reader and writer.
Assume both the semaphores mutex and rw_mutex are counting semaphores and are
initialized with value =1. The timings of activations of Reader/writer Threads or processes are
as given below:
Time Process
T=0 Writer1
T=3 Reader1
T=7 Writer2
T=9 Reader2
Write the transitions of the variables at the given time slots in the tabular format as given
below: If a variable does not undergo any transition at a given time then specify its current
value. When will writer2 complete the write operation?
Ans:
5. The following table shows the code fragments of 3 concurrent processes and 3 binary
semaphores. The semaphores are initialized as S0 = 1, S1 = 0 and S2 = 0. What is the maximum
number of times P0 can print 0?
wait(S0)
print 0
signal(S1)
signal(S2)
} while(1)
Ans: 3 times