We shall very briefly cover the concept of segmentation...
Up til now we have looked at paging. With a pure paging system, the user view of memory is as a large, flat, virtual address space. Like this:
However, this is not necessarily the programmer's view of memory. Memory may be viewed as being full of objects, such as procedures, arrays, structures... Programmer's view is of many, small (and not so small) 1D address spaces:
Often the programmer would like to grow and shrink these objects independantly. With the 1D, paged virtual memory we've been talking about, the programmer is obliged to allocate all these objects in the stack, heap or text segments. The programmer must deal with shrinking and growing objects manually.
Segmentation deals with this programmer's-eye view directly, and introduces a 2D address space.
One part of the address refers to the 'object' (as a segment number); the other part of the address is the position within the segment:
In segmented systems, the programmer is aware of the segmentation, so segments might contain procedures, arrays, even entire files (MULTICS allowed mapping a file onto a segment).
For example, if each procedure were loaded as a segment, as long as all addresses were relative to the segment, could be shared by multiple processes. If the procedure were recompiled, it might be bigger or smaller, but it could replace the old procedure in the segment---the segment could grow or shrink, but references to location 0, par example would still go to the procedure. Segments used to link executable code together.
The two most talked about segmented architectures are the MULTICS operating system, and also the Intel x86 family supports it from the 386 onwards.
Simple way to implement segmentation, is with a segmentation table, pointing to segments in the traditional 1D memory. Each seg table entry has a base and limit field, and typically some protection bits. Note that protection bits make a little more sense in segmentation, than paging, since the programmer is aware of the segments, and what they contain (whereas page boundries are invisible to the programmer):
So, what are the main features of segmentation?
Paging and segmentation are not exclusive. With a pure segmentation scheme, we suffer again from problems of external fragmentation. For this reason, segments are often paged. Both MULTICS and the 386 do this.
Note that it is important both to allow a large number of segments per process, and also large segment sizes. For this reason, virtual addresses in a segmented system---segment plus position within segment---can be very large.