Page 1 of 1

Standard Memory segment Arrangement

Posted: Sat Nov 06, 2010 12:46 am
by Mohanty
How we are arranging memory?
I know basic segment like
1. null segment
2. kernel code segment
3. kernel data segment
4. user code segment
5. user data segment

Now I want to know, each segment takes how much memory. just as example tell me.

and where we are putting stack segment.

In descriptor table we are only describing the above 5-segment. why not other segment.

Re: Standard Memory segment Arrangement

Posted: Sat Nov 06, 2010 5:01 am
by skyking
I use only three: one code segment of 4GiB and one data of 4GiB. I would turn the question back, why would you want a sixth? There's no point in adding more segments without any reason to do so.

Re: Standard Memory segment Arrangement

Posted: Sat Nov 06, 2010 8:04 am
by NickJohnson
Most systems use a flat memory model, meaning all segments (except the null one, of course) have a base of 0 and a limit corresponding to the top of memory. That way, the only difference between the segments is their ring level. Paging is then used instead to do memory protection. If you're using segmentation for memory protection, the size of each segment really depends on what you're doing, although the kernel segments should be flat to give uniform access to memory, and you'll need more than one pair of user segments if you're going to be multitasking.

Also, the stack segment should be the same as the current data segment.

Edit: @skyking: you need to have separate kernel and user segments, otherwise you can't switch ring level, and therefore can't protect the kernel from user code.

Re: Standard Memory segment Arrangement

Posted: Sun Nov 07, 2010 4:11 am
by skyking
NickJohnson wrote: Edit: @skyking: you need to have separate kernel and user segments, otherwise you can't switch ring level, and therefore can't protect the kernel from user code.
So? I can still do multitasking, protection does not need to be a requirement.