When context switch occurs, the TLB is flushed so that incorrect translation is prevented
Protection
3-bit access rights: wrx
1-bit valid bit: is the page valid to access?
Out of range access for some process (e.g. only using first 60% of the page)
Page sharing
Mapping 2 or more processes memory to the same physical frames
Copy-on-write
On forking, map the new process’ pages to the same frame locations
Mark the location as read-only with the access bits
Only when a write is required, will the OS copy the page to a new memory location with write access, and reassign write access to the previous page.
Segmentation
Text, Data, Heap, Stack become individual segments.
Each segment is contiguous
Put into different partitions
Logical Address Translation
Access with <segment id, offset>.
If offset > limit: triggers the SIGSEGV signal (segmentation fault).
Segment
Base (Starting address)
Limit (Max offset)
0 (Text)
…
…
1 (Data)
…
…
2 (Heap)
…
…
3 (Stack)
…
…
Hardware Support
Note: The segment table above is in physical memory, not cached. The addressing error is the issued interrupt signal, i.e. invalid physical address of any sort is never returned.
Pros:
Each segment can grow/shrink independently
Each segment can be protected/shared independently
Cons:
Variable-size contiguous memory regions
External fragmentation
Segmentation with Paging
Each segment has its own page table as an entry in the segment table.
Now each request is <segment id, page number, page offset>.
Segment table consists of <segment id, page table address>.
Each page table then contains the <page number, frame number>.
Memory Management Unit
The memory management unit (to be better understood in Chapter 10) is providing the hardware support for checking the address requests.