Memory Segmentation on 8086, 80286, 80386
Posted: Tue Apr 26, 2011 5:27 pm
I've been learning about memory segmentation on old processors for a while and I have a few questions.
On the 8086 (16 bit segment registers, 20 bit address bus), the only available mode was real mode and a selector:offset scheme was used. The selector pointed to the start of a segment and because the first four bits of the selector were blank, segments overlapped every 16 bytes, correct? Was the scheme supposed to be that they would always overlap or that they would only overlap if an application didn't need all of the space in its segment? Because if they always overlapped then two applications could be accessing the same location in memory which would cause problems, but from what I've read online it seems like there's a new segment every 16 bytes regardless of whether an application is using that memory.
On the 80286 (16 bit segment register, 24 bit address bus), a GDT was used in protected mode. The first 13 bits of the selector accessed an entry in the GDT, which contained a 24 bit linear address and the offset was added to that to find the correct memory address. If only the first 13 bytes of the selector are used to index the table, then the GDT can have a maximum of 2^13 entries which results in 2^13 addresses, which ruins the point of the 24 bit address bus. So how does the GDT allow access to all 2^24 memory addresses? I believe the 80386 uses the exact same system except for the modifications allowing 32 bits, so this question applies to that architecture as well.
Finally, paging seems very pointless if enough memory is available. It seems to me like it would nearly double the amount of RAM if it's used to its full extent (swap every page out, correct?), but if you're not using all of the RAM, the processor needs to process the page fault and resend the instruction even though you could have just mapped the linear address to the physical address without paging. So is paging always on or do operating systems control whether its on or off. And if its always on, why?
Thanks.
On the 8086 (16 bit segment registers, 20 bit address bus), the only available mode was real mode and a selector:offset scheme was used. The selector pointed to the start of a segment and because the first four bits of the selector were blank, segments overlapped every 16 bytes, correct? Was the scheme supposed to be that they would always overlap or that they would only overlap if an application didn't need all of the space in its segment? Because if they always overlapped then two applications could be accessing the same location in memory which would cause problems, but from what I've read online it seems like there's a new segment every 16 bytes regardless of whether an application is using that memory.
On the 80286 (16 bit segment register, 24 bit address bus), a GDT was used in protected mode. The first 13 bits of the selector accessed an entry in the GDT, which contained a 24 bit linear address and the offset was added to that to find the correct memory address. If only the first 13 bytes of the selector are used to index the table, then the GDT can have a maximum of 2^13 entries which results in 2^13 addresses, which ruins the point of the 24 bit address bus. So how does the GDT allow access to all 2^24 memory addresses? I believe the 80386 uses the exact same system except for the modifications allowing 32 bits, so this question applies to that architecture as well.
Finally, paging seems very pointless if enough memory is available. It seems to me like it would nearly double the amount of RAM if it's used to its full extent (swap every page out, correct?), but if you're not using all of the RAM, the processor needs to process the page fault and resend the instruction even though you could have just mapped the linear address to the physical address without paging. So is paging always on or do operating systems control whether its on or off. And if its always on, why?
Thanks.