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.

78 Space Management Chapter 3instructions and may be shared. The second is for data, and the third is for the stack.Each of these segments of virtual space may be composed of several adjacent hardwaresegments. For example, one segment of virtual space could be 23K bytes long by occupyingthree hardware segments on the PDP-11.Having lots of variable-sized segments can be an advantage. Segmentation allowsthe programmer or the compiler to partition the name space of a program — that is, thespace of identifiers such as variables and procedures — into discrete segments. Hardwaresegmentation supports program modularity. For example, a program written in Pascalusually has to check the subscripts of each array reference to make sure they are withinbounds. If a separate segment is devoted to that array, the hardware can automaticallycheck the subscripts and relieve the software of that burden. It is also natural to putlibrary routines in segments by themselves and then share those routines among all theprocesses that might need them.5.1 ImplementationIt is no longer sufficient to use the most significant bit of a virtual address to distinguishwhich segment is being used. Instead, the top m bits of each virtual address are used toselect one of 2 m segments. Of course, the maximum number of segments is therefore2 m . The remaining bits are used to select the offset within the segment. The translationtable now has an entry for each segment, so we call it a segment table. That entry containsthe start, size, and permissions of that segment:1 const2 BitsPerPhysicalAddress = 24; { for example }3 BitsPerVirtualAddress = 16; { for example }4 BitsPerSegmentAddress = 6; { for example }5 BitsPerOffsetAddress = BitsPerVirtualAddress − BitsPerSegmentAddress;6 SegmentLimit = 2 BitsPerSegmentAddress ;7 OffsetLimit = 2 BitsPerOffsetAddress ;8 type9 PhysicalAddress = integer; { containing BitsPerPhysicalAddress bits }10 AccessType = (Read, Write, Execute);11 SegmentTableEntry =12 record13 Start : PhysicalAddress;14 Size : integer; { length of virtual space }15 Permissions : set of AccessType;16 Present : Boolean;17 end;18 var19 SegmentTable : array 0 : SegmentLimit-1 of SegmentTableEntry;20 NumberOfSegments : 0 .. SegmentLimit;If we use the numbers suggested in the declarations (lines 2−4), virtual addresses are 16bits long. Virtual space is therefore limited to 64K bytes. A process may have a virtualspace ranging anywhere between 0 bytes and this limit, divided into segments. Of the 16bits, 6 are used to name the segment. A process may therefore have at most 64 segments,each with a maximum size of 1K bytes. The only way for a process to have a full 64Kbytevirtual space is to have all 64 segments and for each segment to be the full 1K bytes

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

Saved successfully!

Ooh no, something went wrong!