Flat vs Segmented Memory Model
I am trying to understand the flat memory model and the segmented memory model.
Is the flat memory model and the segmented memory model determined by the CPU or OS architecture or both?
Or are they not determined by CPU and OS architecture, but instead are options available to programmers on any computer with any CPU architecture and OS installed?
If the latter, what kinds of programming should be considered with a flat memory model and a segmented memory model? Assembly, C and/or other high-level programming languages?
Early x86 computers used segmented memory model addresses based on a combination of two numbers: the memory segment and the offset within that segment. Some segments were implicitly treated as code segments, reserved for instructions, stack segments, or normal data segments. Although the uses were different, the segments did not have different memory protections to reflect this.
Now many programmers prefer to use a flat memory model in which all segments (segment registers) are generally set to zero and only the offsets are variable.
• Model with flat memory
Not suitable for general computing or multitasking operating systems unless augmented with additional memory management hardware/software; but this is almost always the case with modern CISC processors that implement advanced memory management and protection technology via a flat memory model. Linux, for example, uses a flat memory model comparing X86_memory_segmentation#Practices.
Segmented memory model
Implemented in the original Intel 8086, 8088, 80186, 80286 and supported by the 80386 and all subsequent x86 machines up to the current Pentium and Core 2 processors. This memory model has remained in x86 computers ever since, which now provide multimode operation and rarely run in compatible segmented mode."Flat" model
Ignoring the Harvard model, which was probably the very first model of computer memory, the flat von Neumann storage model was the first model to reach mainstream use. Basically it's that -- a "flat" address space of unresolved words (not bytes until very late in the game) that started at address zero and continued upwards to the "top" of available memory. Some of the "bottom" or "top" memory would be reserved for some kind of "loader", with the rest available to a single executable program. It ran one program at a time, with the program able to use all but this small dedicated area of RAM.
Things slowly changed until the small dedicated area grew to contain some sort of operating system, but still only one program at a time. As time progressed further, various tricks were invented to allow e.g. certain specialized programs to run in a "corner" of memory, allow spooling programs, etc. to coexist with user programs.
But the push for "multi-programming" was building. Some systems added crude address mapping hardware to allow multiple programs to each have their own address space. Other systems required programs to be "self-relocating" to run anywhere in memory as opposed to being "linked" to a specific address.
Early Unix (among other things) handled the task of multiprogramming by "swapping" programs in and out: A program (loaded at address zero) ran until it "blocked" to perform I/O, then it would be "swapped" (in its entirety, including all code and data) to disk and "swapped" another program.
But for the most part, these techniques have slowly evolved (or perhaps transitioned) into various forms of site mapping storage models.
You must be logged in to post a comment.