Segmentation: Generalized Base/Bounds

Get introduced to the concept of segmentation which improves the utilization of the memory space.

We'll cover the following

To solve this problem, an idea was born, and it is called segmentation. It is quite an old idea, going at least as far back as the very early 1960’s1.“Program Organization and Record Keeping for Dynamic Storage” by A. W. Holt. Communications of the ACM, Volume 4:10, October 1961. An incredibly early and difficult to read paper about segmentation and some of its uses. 2. “Fact Segmentation” by M. N. Greenfield. Proceedings of the SJCC, Volume 21, May 1962. Another early paper on segmentation; so early that it has no references to other work.. The idea is simple: instead of having just one base and bounds pair in our MMU, why not have a base and bounds pair per logical segment of the address space? A segment is just a contiguous portion of the address space of a particular length, and in our canonical address space, we have three logically-different segments:

  1. Code
  2. Stack
  3. Heap

What segmentation allows the OS to do is to place each one of those segments in different parts of physical memory, and thus avoid filling physical memory with unused virtual address space.

Example

Let’s look at an example. Assume we want to place the address space from the figure here into physical memory. With a base and bounds pair per segment, we can place each segment independently in physical memory. For example, see the figure below; there you see a 64KB physical memory with those three segments in it (and 16KB reserved for the OS).

Get hands-on with 1200+ tech skills courses.