MMU Implementation Question

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
devr

MMU Implementation Question

Post by devr »

Hello everyone,

How would one implement a segment-based Memory Management Unit ? I know that some of you guys are paging lovers :), but i just wanted to know how to implement the MMU in segments.

I was thinking about few solutions.. one of them is:
1) Create a descriptor for the GDT table itself. So i can access the REAL structure of the GDT and modify it on-the-fly with quick MOVes.

2) When a process asks for memory, create a descriptor on-the-fly with its specific info.

3) When the process end, delete its descriptor.

Looks pretty much logical and easy for me!

Please let me hear your comments and ideas ..

--devr
Tim

Re:MMU Implementation Question

Post by Tim »

Sounds good to me.
devr

Re:MMU Implementation Question

Post by devr »

Are there any better ideas ?? Because i am not 100% sure about this !! There must be someone before me who had implemented a segmented MMU !! ;D

--devr
Tim

Re:MMU Implementation Question

Post by Tim »

There's probably a lot of scope to do interesting things with segments -- look at Windows 3.x or OS/2 for examples. However, the main drawback is that most compilers don't know about segmentation (Open Watcom 1.0 being an exception to this). I can't think of any current OS that uses segmentation, so you're more or less on your own here.
devr

Re:MMU Implementation Question

Post by devr »

Win 3.x !!! is segment-based MMU really that bad ??? ! i thought that segmentation would be faster, although not flexible as paging, since paging require extra delay, thats why i decided to do it in a segmented way !! :-\ But since the size of the memory are increasing nowadays, but not at the same rate for the speed of the chips, i thought i'd better to consentrate on the speed; because it isn't as rapidly evolving as the size.

I still need comments from you guys !

Thanks ..

--devr
Tim

Re:MMU Implementation Question

Post by Tim »

No, segmentation is quite a bit slower. The main source of slowdown is segment register reloads (and hence far calls), because of the extra checking performed by the CPU. Another slowdown is the overhead of processing segment override prefixes on instructions.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:MMU Implementation Question

Post by Pype.Clicker »

i confirm Tim for the slowness... moreover, it wouldn't be fine to use a new segment everytime a program requests memory (for instance using malloc()) , because you only have up to 8192 entries in a LDT (which is the best place to hold process-specific resources), and you can't restrict the user to only 8192 memory chunks.

What you could do, however, is using call gates and protected segments when an untrusted program wants to have access to a trusted library, using the MMU like a sandbox-helper :)
Post Reply