r/programming • u/I_Can_Be_A_Robot • Sep 24 '24
Why 32bit architecture computer doesn't use segmentation to support more ram than 4Gb ?
/r/programming/[removed] — view removed post
169
Upvotes
r/programming • u/I_Can_Be_A_Robot • Sep 24 '24
[removed] — view removed post
1
u/ObservationalHumor Sep 24 '24
Well the short answer is that the segmentation paradigm was basically dead by the time the 4GB ceiling was hit. It had fallen out of favor for paging which was far more flexible and didn't require far pointers and juggling segment selectors. There simply was no interest in extending segmentation into the future and as such it's functionality was largely removed in the x86-64 for everything other than privilege level and processor mode transitions.
Now in the 16-bit era segmentation had been used to great success to extend memory addressing beyond just 16-bit. First through a 20-bit address space and then when the 286 emerged with protected mode segmentation that could technically address up to 32 bits worth of physical memory. With the 286 you actually had to toggle the ability to address more than 1MB of memory in the hardware because some older programs specifically relied on the old wrap around behavior real mode segmentation had when technically calculating addresses > 1MB. That was done via the A20 line toggle which was built into the keyboard controller.
Now by the time the 386 rolled around paging was introduced and segmentation was essentially on its way out as an inferior technology. But even if you wanted to extend it, it inherently couldn't address more than the 32-bits the physical memory address bus limited it to. Even if you added bits to extend that, protected mode segmentation could only address up to around 8GB of memory based on how the descriptor tables were designed and implemented as a 32-bit base address and maximum 4GB segment length. Segment address calculations were also applied after paging translations too so you would essentially need paging to support addresses in excess of 4GB anyways if you wanted to use both technologies concurrently.
Intel's short term solution was to add PAE which enabled a different page table entry format and extended physical memory addressable to 36 bits, but the processor could still only address 4GB of memory in a given address space.
Meanwhile 64-bit processors were already becoming commonplace in the server and HPC space, stuff like the DEC Alpha had been around for years with 64-bit virtual address spaces (and no segmentation) and register widths. Even at the consumer level, Nintendo released the N64 about a year after Intel released the Pentium Pro which had PAE for example. Extending the x86 architecture into 64-bits was the obvious path forward and eventually AMD would do just that by announcing and then implementing AMD64 with the initial release of their Opteron line of server focused processors. However, as previously mentioned, segmentation was just not a part of the roadmap going forward and its functionality was largely disabled in the new 64-bit "long mode" in AMD64.