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 79in length. In our example, a physical address is described by 24 bits. The largest amountof physical store that may be placed on the machine is therefore 16M bytes. A particularmachine may have less store, of course. Main store for computers of this size is usuallypurchased in increments of 256K, 512K, or 1M bytes.The algorithm used by the hardware on every access can be represented as follows:21 procedure Translate (VA : VirtualAddress; AT : AccessType) : PhysicalAddress;22 var23 Segment : 0 .. SegmentLimit - 1;24 Offset : 0 .. OffsetLimit - 1;25 begin26 Segment := VA div OffsetLimit;27 Offset := VA mod OffsetLimit;28 if Segment ≥ NumberOfSegments then29 trap("invalid segment number");30 else31 with SegmentTable[Segment] do32 if not Present then33 trap("missing segment");34 { segment fault; not an error }35 elsif Offset ≥ Size then36 trap("offset out of range";37 elsif not AT in Permissions then38 trap("security violation");39 else40 Translate := Start + Offset;41 end; { if }42 end; { with }43 end; { if }44 end Translate;Figure 3.11 shows the algorithm followed by the hardware on every access to translateand check addresses. As a concrete example, consider the following situation. Again, letus use decimal notation. Assume that a virtual address is three digits long and physicalstore has 20,000 bytes, as before. Assume that the first digit determines the segmentnumber and the other two digits determine the offset.Segment TableSegment number Start Size Permissions Present0 13426 26 RWX yes 1 2309 00 R yes 2 1000 23 WX yes 3 — 95 W no 4 10000 100 RWX yesNumber of segments = 5R = Read, W = Write, X = Execute

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

Saved successfully!

Ooh no, something went wrong!