Hi,
0x57 wrote:
As the result, I guess I'd go for the Intel manual to see what features are still exists there, what are the pros and cons, etc.
Intel's manual will describe how segmentation works, what it's capable of and how to set it up; but it won't tell you what it could be used for, or the advantages/disadvantages of using it in various ways.
For a very rough guide, there are 4 possible combinations:
No segmentation, no paging: This means no protection, no way to isolate pieces of code from each other, no way to deal with fragmentation, no way to handle various virtual memory techniques (copy on write, swap space, memory mapped files, etc). Despite being "underpowered" it actually can make sense in very specific situations (e.g. an embedded thing that only runs one application and doesn't need any memory management).
With segmentation, no paging: There's 2 ways of doing this:
- small number of large segments. This solves the protection/isolation problem; but ends up being a huge disaster for everything else (memory fragmentation, copy on write, swap space, memory mapped files, etc).
- large number of small segments. This solves the protection/isolation problem and makes it more possible to do the other things (in an over-complicated and ugly way). The main disadvantage is that loading a segment register is slow, and when you're loading segment registers often it can be a serious performance problem.
Note that for both of these cases there's a "virtual address space size" shortage. For example, if you've got a 32-bit CPU with 12 GiB of RAM then you can't use most of the RAM. Don't forget that in long mode you have to use paging, so you can't use the "
48-bit virtual addresses should be enough until next week" excuse in this case.
No segmentation, with paging: This is capable of doing almost everything, and (once you understand paging) it's relatively easy. The only thing it can't do is things like checking if array accesses are in range (but if you care about that then you should be using a managed language to begin with).
With segmentation and with paging: This is a pointlessly overcomplicated mess (use paging on its own, or using paging and a managed language).
Cheers,
Brendan