2. Address Translation Examples

Segment    VA     Base  Size
-------  ------  -----  ----
   Code   0-2K   32768   2K
   Heap   4-7K   34816   3K (grows positive) [4K = 4096] [34816 + 3K = 37888]
  Stack  16-14K  28672   2K (grows negative) [16K = 16384]

Virtual Address 100 (Code) --> Physical Address 32768 + 100 = 32868

Virtual Address 4200 (Heap) --> Physical Address 34816 + (4200 - 4096) = 34920

Virtual Address 15360 (Stack) --> Physical Address 28672 - (16384 - 15360) = 27648

Segmentation Violation = Segmentation Fault = Illegal Virtual Address:

  Virtual Address 8000 (Heap) --> Physical Address 34816 + (8000 - 4096) = 38720 ≥ 37888