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 771 const2 BitsPerPhysicalAddress = 24; { for example }3 type4 PhysicalAddress = integer; { BitsPerPhysicalAddress bits }5 AddressTranslationEntry =6 record7 Start : PhysicalAddress;8 Size : integer; { length of virtual space }9 Permissions : set of (Read, Write, Execute);10 end;11 var12 AddressTranslationTable =13 array 0 : 1 of AddressTranslationEntry;The three permissions in line 9 require some explanation. ‘‘Read’’ means that the processmay access the segment to find operands for operations. ‘‘Write’’ means that theresults of operations may be stored in the segment. ‘‘Execute’’ means that the processmay access the segment to find instructions. A common arrangement would be to haveRead and Write permission on the lower segment and only Execute permission on theupper one.The upper segment is sometimes shared for a different purpose, however. Verylarge programs cannot fit in one address space. They are split into several processes thatcommunicate through shared data. Those shared data are placed in a shared upper segment.Now the upper segment has Read and Write privilege, whereas the lower has onlyExecute. Other combinations are possible as well.Data structures to keep track of shared segments are more complicated. If a segmentshould be swapped out, it must be marked that way in the context block of eachprocess sharing it. To find those processes, an auxiliary shared-segment table is preferableto a complete search of all the context blocks. This table lists all shared segmentsand the processes that are using them.Policy decisions for swapping shared segments are also more complicated. Ashared segment should be less likely to be swapped proportionally to the number of nonblockedprocesses that are using it. Tying shared segments down, however, is not a goodidea because the processes that share the segment might all be in wait lists for a longtime.Instead of discussing the two-segment case in any greater detail here, let us postponeour curiosity and turn immediately to the more general case.5 SEGMENTATIONWe will now allow each process to have a number of segments, numbered 0 throughn −1, where the process has n segments. There will be some limit on the number of segmentspermitted, determined, of course, by the hardware. On the DEC PDP-11, there canbe eight segments, each 8K bytes long. This limitation, both in the number of segmentsand in their maximum length, has led operating systems for the PDP-11 either to ignoresegmentation entirely and give each process just one contiguous space or to restrict theuse of segments. Unix, for example, gives each process three segments. The first is for

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

Saved successfully!

Ooh no, something went wrong!