You are on page 1of 1

Exercise: OS

1 A thread P1 prints “I am process A” 3 times and the thread P2 prints “I am process B” 4 times. The
threads must execute in concurrent fashion. Following is the mandatory output. Employ semaphore
to print the output in correct order

I am process A
I am process B
I am process A
I am process A
I am process B
I am process B
I am process A

2 Assume that a Process A increment a variable and process B decrement the same variable
synchronously. The variable must not be less than Zero and greater than 1. The increment and
decrement operations must be performed in critical section to check lower and upper limits. Provide
implementation by employing Peterson’s solution.

3 Provide the implementation of test and set () AND compare and swap() instructions in a real
scenario.

4 Provide the implementation of Acquire () and Release () Functions. Assume that two threads have
intentions to swap the values of two globally declared arrays.

5 Provide the implementation of readers/writers solution using monitors.

6 Provide the implementation of a Mutex to ensure the value of a counter must be binary, i.e., 0/1.

7 Propose an optimal solution of Dining Philosopher Problem to avoid the deadlock and starvation by
employing process synchronous techniques.

You might also like