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.

Segmentation 83The hardware either stores the entire segment table in registers if it is short or usesa cache to store the most frequently used entries, in conformance with the Cache Principle.If the hardware had to refer to main store each time it needed to translate an address,the effective speed of the machine would be halved. The storage manager does not needto know anything at all about the cache, except that whenever the kernel modifies thesegment table itself, for example when switching processes, the hardware must find outwhich entries in the cache are invalid. Machines that have such translation look-asidebuffers, as we will call these caches, have an instruction called ‘‘flush the cache,’’ whichinforms the hardware that all the entries in its cache, if any, are no longer valid. The kernelshould execute this instruction as part of process switching.5.5 Shared segmentsTwo processes that share a segment don’t have to use the same segment number, norneed they have identical privileges over that segment. One process could call it segment5 and have RX privileges, and the other could call it segment 1 and have WR privileges.This segment has two separate entries, one in the segment table for each process. Thesame physical segment may even appear twice in the virtual space of one process. However,sharing an instruction segment with different segment numbers can be difficult.Such segments tend to refer to themselves (in jumps, for example). These referencescannot have the segment number as part of the instruction. Instead, they must refer to aregister that holds the segment number.Shared segments cause problems with Dirty fields because a shared segment maybe written by process A, and then swapped out when process B is running. The hardwareonly knows about process B’s segment table at this point, and the table will not indicatethat the segment is dirty unless B has written into it. The storage manager must consult ashared-segment table in order to track down all the Dirty fields that correspond to thisshared segment in all the context blocks for the processes that share it.5.6 Unusable spaceSegmentation creates three kinds of unusable space that cannot be applied to any process.Free pieces of physical store that are not in use at the moment are wasted. Some ofthese pieces may be too small to be of any use until the storage manager shufflesthe current segments. We will call such unusable space external waste, since it isoutside the space of any process. We also saw external waste under the partitionmethod.Context blocks must hold copies of the segment table during the time that a processis not running. Space devoted to the segment table cannot be put to other useswhen the process is running; it is a fixed cost of segmentation. If the segmenttables are large, they may be swapped out to reduce this cost. Space that is

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

Saved successfully!

Ooh no, something went wrong!