Standard Memory segment Arrangement

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
User avatar
Mohanty
Member
Member
Posts: 28
Joined: Fri Jul 30, 2010 9:15 am
Location: India
Contact:

Standard Memory segment Arrangement

Post 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.
skyking
Member
Member
Posts: 174
Joined: Sun Jan 06, 2008 8:41 am

Re: Standard Memory segment Arrangement

Post 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.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: Standard Memory segment Arrangement

Post 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.
skyking
Member
Member
Posts: 174
Joined: Sun Jan 06, 2008 8:41 am

Re: Standard Memory segment Arrangement

Post 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.
Post Reply