Why does everyone use paging?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
joke
Member
Member
Posts: 56
Joined: Sat Jul 22, 2006 6:20 am

Why does everyone use paging?

Post 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) ???
I need someone to show me the things in life that I cant find
I cant see the things that make true happiness, I must be blind
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Post 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.
User avatar
matthias
Member
Member
Posts: 158
Joined: Fri Oct 22, 2004 11:00 pm
Location: Vlaardingen, Holland
Contact:

Post by matthias »

I think you should read the following topic:

http://www.osdev.org/phpBB2/viewtopic.php?t=2736
The source of my problems is in the source.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post 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
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post 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
Legend
Member
Member
Posts: 195
Joined: Tue Nov 02, 2004 12:00 am
Contact:

Post 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.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post 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
Legend
Member
Member
Posts: 195
Joined: Tue Nov 02, 2004 12:00 am
Contact:

Post by Legend »

I guess that is why 32-bit cpus have been invented. ^^
Post Reply