Question

I'm a bit confused about pure segmentation due to in my head always existed the idea of virtual memory.

But as I understand pure segmentation is also imagining a virtual address space, divided in segments that are ALL loaded in RAM.

The difference with virtual memory with segmentation, is that possibly there's some segment that it's not in RAM.

Is this correct?

I ADD A QUESTION: Is there a practical difference between segmentation combined with paging, and a two-level paging?, it's the same except for the "limit" protection of the segment method. Or there's another difference?

Was it helpful?

Solution

No, it's not correct. For example, on x86, segmentation uses "far" pointers that consist of two parts: the segment selector (loaded into a segment register, e.g., DS) and an offset into the segment. Segment offsets always begin at 0. The CPU uses the segment selector to find the segment descriptor which contains the segment's LINEAR base address, length and access rights. All accesses are length-checked; if you try to access memory outside of the segment limit or with invalid access (e.g., writing to a read-only segment), the CPU will generate a general protection fault.

Since segment addresses are always zero-based and the segment base is implicit in the segment selector, the OS can move segments around and defragment memory without affecting the programs using that data. (Contrast this with the "flat" memory model where if you move some data, you also have to update all pointers pointing to it.)

Now, when paging is disabled, the LINEAR segment base address is its physical memory address. When paging is enabled, all accesses to segment data are translated by the MMU as usual.

OTHER TIPS

If you're serious about understanding memory management at this level, an excellent explanation can be found by reading Operating System Concepts by Silberschatz, Galvin, and Gagne. You should be able to find an inexpensive, older edition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top