In 8086 microprocessor, we segment the memory into segments of 64K each because of the 16 bit registers (Since a 20 bit address cannot be stored in the 16 bit register). These segments are categorized as code segment, data segment, stack segment and extra segment. This structure is similar to that of created by a process in operating system. Does that mean each process takes up memory equivalent to 4 segments which will be equivalent to 4*64K in case of 8086 ? And if this is true then by doing some more math we can say that only 4 process will be handled by a 8086 microprocessor at a time (i.e. one of the process will be running state and others would be in block or ready state) since maximum of 16 segments are possible (Total memory size / size of each segment = 1MB/64K = 16).
I have just started studying this and saw this equivalence between process and segments. Does any such connection between the segments of the memory and the memory structure of the process actually exists or it's just my crazy imagination ?

- 328,167
- 45
- 605
- 847

- 15
- 7
-
2CS/DS/ES/SS can all point at the same segment (and they can overlap). A program may not even need the entire 64KiB that a single segment can reference directly. It really comes down to the design of a real-mode OS. A note. Although an 8086 could address 1MiB of memory the upper 384K was usually left to hardware and peripherals (although there were gaps that could be RAM). That left the lower 640KiB free. A real mode OS could swap programs in and out of memory to disk or to memory on expanded memory boards that could have many megabytes of additional memory (like LIM expanded memory boards) – Michael Petch Dec 21 '20 at 17:48
-
1If you are curious about LIM memory and how that works this is a good reference: http://www.phatcode.net/res/218/files/limems40.txt – Michael Petch Dec 21 '20 at 17:50
-
2If you meant compared to a *modern* x86 OS, then no, there's no connection, they use paging not segmentation, and terms like "data segment" have a basically unrelated meaning. e.g. [Linux memory segmentation](https://stackoverflow.com/q/56213569) and [What is the purpose of segment registers in x86 protected mode?](https://stackoverflow.com/q/15335003). But I think you're asking about an 8086 OS that really does use segmentation to allow loading multiple programs in real mode. – Peter Cordes Dec 21 '20 at 18:35
1 Answers
A little history helps. Early UNIX(tm) ran on the Digital pdp minicomputer family. The first circulated versions were V6 & V7, which were exclusive to the pdp-11 family. That family could support a whopping 256K of RAM; but the gp register set (used for address formation) were 16bits wide. There was a limited memory protection scheme in the processor, which permitted the kernel (supervisor) to have a separate address space from user (user); and instructions (addresses generated by pc) to be separate from data (generated by other means). This will probably get edited into the dust by pdp-11 fanbois
.
At around this time, intel was rolling what was to become the 8086. Current 8-bit CPUs were already straining at a 64K address space limitation, and were using a concept called bank switching
to increase that. In bank switching
, some sub-ranges of the 64K address space could be re-pointed into a larger memory bank; so although you could carefully address much more memory. The Hitachi 64180 was one of the CPUs that incorporated this into its silicon; most used external memory controllers.
The 8086 addressing scheme was an amalgamation of these notions. You could produce an Operating System which supported dynamically relocated processes and shared text with up to 64K Instruction + 64K Data. The general idea was you take the segment registers out of the programming model, thus if the OS has to relocate the process, it knows that the process had no saved copy of the old segment value. The commercial OS QNX 1.x, 2.x
provided this as a model; the later using the 286 extensions to protect against programs that played with the segment registers.
For programs that didn't care about such subtleties (Lotus 123, ...), you could use the segment registers to effectively create a 2^20 address space on the 8086. It is an ugly programming model in this mode because address formation is A=Seg*16+Base
, so Seg=1,Base=0 and Seg=0,Base=16 resolve to the same address.
So, you aren't hallucinating, it was quite intentional, if more than a little half-arsed.

- 10,070
- 1
- 21
- 33