Page 1 of 1

Segments initiation problem

Posted: Fri Nov 30, 2012 12:55 am
by afdgdhfrtewdszs
Hi,
I am confused at the point where we set registers as soon as we into protected mode. Especially when setting stack-segment with the same selector as data-segment. This means that they will have the same base-limit address. My question is this: Stack,data and code won't 'interfere' with each other while they are in the same segment(just different access-types)?Thanks.

Re: Segments initiation problem

Posted: Fri Nov 30, 2012 2:09 pm
by Mike
Hello,

The code, data, and stack all share the same linear address space and so can interfere with the others if not careful. This reflects a flat address space where segmentation is not used (all kernel segments start and end at the same place.) Of course, you can always still use segmentation but its not really useful if you plan to use paging and makes compatibility harder (other architectures that don't support it and C compilers that assume a flat memory model.)