Page 1 of 1

Why does everyone use paging?

Posted: Fri Aug 18, 2006 2:07 pm
by joke
Hi all,

Why do we see too many paging projects and none for segmentation? I mean there are many segmentation options like multi-segment mode and others that could be used. For example, we could implement multi-segment mode as follows:
First there is a gdt with three segments stack,code,data for the kernel, but not overlapping, leaving a big portion of memory unsegmented. Every time a new process is created, the kernel modifies the gdt for three new segments, issues a lgdt command and points the TSS of this process to these new segments. And this continues for all processes. So we have multiple segments.

That was my first question, my second is why is segmentation disabled in IA-32e (64-bit mode) ???

Posted: Fri Aug 18, 2006 2:32 pm
by SpooK
Because Segmentation is not as friendly to multi-tasking as Paging is... things get bulky and there is way too much overhead when you try to achieve decent security. Furthermore, your idea of "leaving a big portion of memory unsegmented" only works in theory, read up on the "15MB Hole" for starters.

Segmentation was adequate when you had single-tasking 16-bit Real Mode Operating Systems, that rarely holds for 32-bit Protected Mode and would be extremely inadequate for 64-bit Long Mode. The x86 64-bit architecture developers realize this (at least AMD), hence why they are trying to finally phase it out.

The only way you could really achieve modern-day OS standards with Segmentation is to use, maybe, a form of JIT or some extreme form of Position Independent Data/Code... but once again... more work just dealing with the overhead.

Posted: Fri Aug 18, 2006 2:49 pm
by matthias
I think you should read the following topic:

http://www.osdev.org/phpBB2/viewtopic.php?t=2736

Posted: Fri Aug 18, 2006 7:25 pm
by earlz
well because hardly any languages support 32bit far pointers(theirs jsut asm and a new watcom C that I know of)

also not cross-platform and more recently would not work when you convert to 64bit

Posted: Fri Aug 18, 2006 9:50 pm
by carbonBased
Not to mention virtual memory (ie, paging to disk, or external device) is not possible without paging hardware.

And if you intend to port to another platform, very few (none, that I use) actually support segmentation.

--Jeff

Posted: Sat Aug 19, 2006 4:13 am
by Legend
carbonBased wrote:Not to mention virtual memory (ie, paging to disk, or external device) is not possible without paging hardware.
If I remember correctly 16-Bit OS/2 could use swap space. Sadly however, they had to swap out complete segments (64kb on the 80286).
And if you intend to port to another platform, very few (none, that I use) actually support segmentation.
Very true.

Posted: Sat Aug 19, 2006 3:46 pm
by carbonBased
Legend wrote:
carbonBased wrote:Not to mention virtual memory (ie, paging to disk, or external device) is not possible without paging hardware.
If I remember correctly 16-Bit OS/2 could use swap space. Sadly however, they had to swap out complete segments (64kb on the 80286).
I suppose that could be possible... I never really thought about segment swapping. I don't think that's overly practical in protected mode, though. In order to get an effective basic swapping unit size, you'd need lots of segment descriptors, and then you can no longer make use of a nice elegant flat memory model. And far pointers are slow, of course... I generally try to limit the number of selector loads.

Cheers,
Jeff

Posted: Sun Aug 20, 2006 3:14 am
by Legend
I guess that is why 32-bit cpus have been invented. ^^