Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

opretaing system 1. Explain why interrupts are not appropriate for implementing

ID: 3761333 • Letter: O

Question

opretaing system

1. Explain why interrupts are not appropriate for implementing synchronization primitives in multiprocessor systems.

2. Servers can be designed to limit the number of open connections. For example, a server may wish to have only N socket connections at any point in time. As soon as N connections are made, the server will not accept another incoming connection until an existing connection is released. Explain how semaphores can be used by a server to limit the number of concurrent connections.

3. Consider the traffic deadlock depicted in Figure 1.

a. Show that the four necessary conditions for deadlock indeed hold in this example.

b. State a simple rule for avoiding deadlocks in this system.

Explanation / Answer

1: Interrupts are not sufficient in multiprocessor systems since disabling interrupts only prevents other processes from executing on the processor in which interrupts were disabled; there are no limitations on what processes could be executing on other processors and therefore the process disabling interrupts cannot guarantee mutually exclusive access to program state.

2:A semaphore is initialized to the number of allowable open socket connections. When a connection is accepted, the acquire() method is called; when a connection is released, the release() method is called. If the system reaches the number of allowable socket connections, subsequent calls to acquire() will block until an existing connection is terminated and the release method is invoked.

3:(a) The four necessary conditions for a deadlock are

(1) mutual exclusion;

(2) hold-and-wait;

(3) no preemption; and

(4) circular wait.

The mutual exclusion condition holds since only one car can occupy a space in the roadway.

Hold-and-wait occurs where a car holds onto its place in the roadway while it waits to advance in the roadway.

A car cannot be removed (i.e. preempted) from its position in the roadway.

Lastly, there is indeed a circular wait as each car is waiting for a subsequent car to advance.

The circular wait condition is also easily observed from the graphic.

(b) A simple rule that would avoid this traffic deadlock is that

a car may not advance into an intersection if it is clear it will not be able immediately to clear the intersection.