13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The problems 259process Aprocess B1 BeginRegion; BeginRegion;2 x := 3; x := 5;3 EndRegion; EndRegion;The form of the delimiters, exactly what a region means, and how it is implemented distinguishthe methods we will survey. In all cases we can look upon regions as a way ofimposing a degree of determinism on a non-deterministic situation, since we can’t predictwhen interrupts will happen, when activities will be scheduled, or the relative speeds oftruly simultaneous activities in a multiprocessor.1.2 SynchronizationMutual exclusion prevents an activity from entering a region until other activities are outof conflicting regions. If we want to prevent an activity from continuing until some moregeneral condition is met, we say that we wish to synchronize the activity with the condition.Synchronization is a generalization of mutual exclusion.Occurrence of conditions marks the passage of time. Synchronizing with thoseconditions achieves a common notion of time among activities. This idea of commontime gives rise to the word ‘‘synchronization.’’Since synchronization is a generalization of mutual exclusion, we can expect thatthe techniques developed for solving the mutual-exclusion problem are also useful forachieving synchronization. We will test this expectation by presenting various synchronizationproblems. The first one is best described by a synchronization graph, whichshows precedence constraints that govern when actions may begin. Figure 8.1 shows thegraph we will discuss. Action A has no preconditions. Once it has finished, actions Band D may start. As soon as B has finished, C may start, but E must wait for both B andD to finish. I may not start until everything else has finished. Each arrow in this graph isa synchronization step. It represents the condition that the action at its tail has finished.There are many ways to cast this graph into a program. We might code each of thenine actions separately and provide for explicit synchronization. Alternatively, we couldcast each row as a separate activity. The first activity would execute A, then B, then C.Synchronization between these pieces would be implicit. The second activity, whichexecutes D, E, and F, would synchronize with conditions created by the first activity inthree places. The last activity is similar. <strong>An</strong>other alternative is to represent each columnas an activity.Choosing an alternative affects which synchronizations are implicit and which areexplicit. It also affects how we perceive the flow of control. For example, this synchronizationgraph could represent the steps needed to complete three Fortran compilations ina simple operating system. Each compilation is represented in one row. The rowrepresents, for example, reading the source program from disk, compiling, and writingthe result to tape. If there is only one disk drive and one tape drive, and we don’t allowtwo compilations to proceed simultaneously, the precedence constraints in the graph

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!