Flat vs Segmented Memory Model

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
desjardins
Posts: 7
Joined: Fri Feb 04, 2005 12:00 am

Flat vs Segmented Memory Model

Post by desjardins »

Im trying to ensure I understand the difference and implications of one model over the other.

Flat is where you set up 2 Segments in the GDT, a Code and a Data segment, both running at CPL=0, and set to use from 0 -> 4GB of memory.

Segmented is where you set up (for example) 4 Segments in the GDT, a Code and Data segment running at CPL=0 using say the first 1MB of memory; and a Code and Data segment running at CPL=3, which uses from 1MB -> 4GB of memory.

If you choose the segmented model, when you perform a System Call you would need to modify CS and DS to point to the kernel segments, and then restore them where you exit correct? The OS would still be responsible for ensuring 2 user processes do not access each others memory, but the cpu can now ensure user processes do not touch kernel memory.

Under the flat model, the os is responsible for all memory security.
---
Unfortunately, while all answers are replies, not all replies are answers
jcmatias
Posts: 11
Joined: Mon Nov 08, 2004 12:00 am
Location: Ribeirao Preto SP Brasil

Re: Flat vs Segmented Memory Model

Post by jcmatias »

1-The relation CPL/DPL is arbitrary - project dependent only.
2-Segmentation don't depend only of OS - There are few compiler that suport segmentation in 32 bits. OS menange securrity in any model of memory - A hardware security can be achived by virtual memory suported by a large number of architetures.
3 - Segmentation is out of future x86 .
4 - Segmentation increase the programing dificulty.
Post Reply