13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

76 Space Management Chapter 3When it has been decided to swap out a segment, either because shuffling is consideredtoo expensive or because it wouldn’t help anyway, which segment is the best victim?First, processes that are in wait lists are good victims. However, in some situationsa waiting process must not be swapped out. If the process is waiting for completion ofsome transput and the operating system has told the relevant device to perform thetransfer directly to main store (by a technique known as direct memory access or DMA,which is described in Chapter 5), the segments involved must not be swapped out or evenshuffled until the transfer is complete. Most DMA devices do not translate addresses butrather deal directly with physical addresses. Even those that do translate addresses mightget confused if the translation table changes in the middle of a transfer. We therefore tiedown any segment that is undergoing DMA transput, rendering it unfit for swapping orshuffling.For segments that belong to waiting processes and are not tied down, one policywould be to pick the one that belongs to the process that has been waiting the longest.Instead of discussing the ramifications of this policy here, let us defer that discussion toour treatment of paging, which has a similar problem.If the foregoing methods have still not resulted in adequate space, some ready processmust be swapped out. We will place such a process in a main-store wait list (in themedium-term scheduler). Once a process has entered that list, it should remain there fora while, or the cost of swapping it out is not justified by the amount of use we make ofthe space it makes available. Once a process is released from the main-store wait list, weshould try not to penalize it again in the near future. The medium-term scheduler is incharge of the policy that honors some processes with ready status and victimizes othersby swapping them out.4 TWO SEGMENTSThe method just discussed, which gives every process a single segment, can be generalized.The first extension is to give each process two segments. In fact, the DEC PDP-10does just that.Virtual space is divided into two non-contiguous regions. They can be distinguishedby the convention that addresses with a 1 in the most significant bit belong tothe ‘‘upper’’ segment. The hardware uses two base-bound registers, one for each segment.With two segments, sharing is finally possible. The convention is to put theinstructions of shared programs, like compilers and editors, in the upper segment and toput local data in the lower segment.It is important that the shared segment not be accidentally or maliciously modified.For this purpose, a ‘‘permissions’’ field is placed in the base-bound register, that is, theaddress-translation table, which now looks as follows.

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

Saved successfully!

Ooh no, something went wrong!