# Operating systems

1. Assume a system has P processes and R identical units of a reusable resource. If each process can claim at most N units of the resource, determine whether each of the following is true or false and prove your claim:(a) If the system is deadlock free then R ≥ P(N – 1) + 1.
(b) If R ≥ P ( N – 1) + 1 then the system is deadlock free.
2. ( 10 points )
In this problem you are to compare reading a file using a single-threaded file server and a multithreaded server. It takes 15 msec to get a request for work, dispatch it, and do the rest of the necessary processing, assuming that the data needed are in a cache in main memory. If a disk operation is needed, as is the case one-third of the time, an additional 75 msec is required, during which time the thread sleeps. How many requests/sec can the server handle if it is single threaded? If it is multithreaded?
3. ( 10 points )
Suppose we use the following to denote a resource graph:Pi : process i
Rj: resource type j; can have 1 or more units
Pi → Rj : Pi is making a request for resource Rj
Pi ← Rj : one unit of resource Rj has been assigned to PiConsider the following resource graph: R1 has two units, R2 has two units, and R3 has one unit,
• P

1 → R1, P2 → R2, P3 → R2, P4 → R2, P5 → R3
P4 ← R1, P3 ← R2, P5 ← R2, P3 ← R3,

Draw the graph. Give an example of a knot in the graph and explain why it is a knot. If you find that there’s no knot in the graph, express the answer as an empty set.

4. ( 10 points )
Consider the state of a system with processes P1, P2, and P3, defined by the following matrices.max-Avail A = ( 5 2 4 )
Max-Claim B = 2 2 2 1 2 2 3 1 3
Allocation C =
 1 1 0 1 0 1 1 1 1

a) Find the available matrix D and need matrix E in this state.

b) Suppose now process P1 makes a request with

F1 = ( 0 0 1 )
If the request were granted, what would be  the D, C, and E in the resulted state?

c) To ensure the system be safe, should the request be granted? Why? Give your reasons in detail.

5. ( 20 points )
Make use of condition variables to implement the barrier problem in Java. A barrier is a synchronization construct that set up for a specified number of threads, say n. Thread that have entered the barriercannot exit until all n threads have entered. Once all threads have entered and they being to exit, the barrier resets itself so that another set of n threads enter again, which again cannot exit until all have entered. 