Microkernel, Memory Manager: Kernel Mode VS User Mode

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
zeitue
Member
Member
Posts: 88
Joined: Fri Dec 14, 2012 6:05 pm
Libera.chat IRC: zeitue
Location: United States, Texas
Contact:

Microkernel, Memory Manager: Kernel Mode VS User Mode

Post by zeitue »

For speed purposes is it better to have the I/O memory and the virtual memory in user mode or kernel mode?

what are the advantages and disadvantages of both?

Thank you
### Z++; && S++; ###
zeitue is pronounced zeɪtə
Web Site::Bit Bucket
Programming Languages: C, C++, Java, Ruby, Common Lisp, Clojure
Languages: English, zɪ̀ŋ, 日本語, maitraiuen
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Microkernel, Memory Manager: Kernel Mode VS User Mode

Post by Brendan »

H,
zeitue wrote:For speed purposes is it better to have the I/O memory and the virtual memory in user mode or kernel mode?

what are the advantages and disadvantages of both?
In general; the advantages of having something in user mode is that the rest of the OS is better shielded from bugs in that thing and it's easier to replace that thing while the OS is running; and the disadvantages are that it costs some performance because you have to do task switches to use it and it can be a little more work to design/implement.

For something like a virtual memory manager; if there's bugs in the virtual memory manager then anything can get messed up anyway; replacing it while the OS is running is excessively messy and error prone; the extra overhead can have a significant effect on overall system performance; and it's a lot harder to figure out things like how page faults get sent using IPC and how to allow a process to examine/modify a completely different process's page tables, etc.

Basically, the advantages of putting something in user space don't really apply for a virtual memory manager, and the disadvantages are worse than they are for other things.

Of course you can break pieces off of the virtual memory manager and run some of those pieces in user space. For example, for memory mapped files the virtual memory manager can send requests for reading/writing data to a virtual file system layer in user space, and you can have something like a "swap space manager" in user space (where the virtual memory manager asks the swap space manager to store and retrieve pages of data).

For IO memory, I'm not too sure exactly what you mean (the IO memory itself is in hardware and therefore isn't in software). I would have a "device manager" in user space, which is responsible for using PCI configuration space to determine which devices use which memory mapped IO areas (and is also responsible for starting and monitoring device drivers); where the device manager tells the virtual memory manager which processes/drivers are allowed to access which memory mapped IO areas.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
zeitue
Member
Member
Posts: 88
Joined: Fri Dec 14, 2012 6:05 pm
Libera.chat IRC: zeitue
Location: United States, Texas
Contact:

Re: Microkernel, Memory Manager: Kernel Mode VS User Mode

Post by zeitue »

@Brendan Hi, thanks for the reply and information.
You probably give the best answers on here from what I've seen

sorry I wrote I/O Memory while thinking of Physical Memory.

For my new OS I think I'll keep the memory management in the kernel mode instead of user mode.

Would process management be somewhat like this as well?

Currently in my new OS design I have a Process manager/server that will handles process ID, group ID, signals, fork, and exit

In addition I'm going to have a Execution manager/server that will load and link executables and handle a byte code format.
### Z++; && S++; ###
zeitue is pronounced zeɪtə
Web Site::Bit Bucket
Programming Languages: C, C++, Java, Ruby, Common Lisp, Clojure
Languages: English, zɪ̀ŋ, 日本語, maitraiuen
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Microkernel, Memory Manager: Kernel Mode VS User Mode

Post by bluemoon »

Some people put the context switch in kernel space for performance, while the scheduler (task picker) that handle load balancing and policy may be a user-space server.
User avatar
zeitue
Member
Member
Posts: 88
Joined: Fri Dec 14, 2012 6:05 pm
Libera.chat IRC: zeitue
Location: United States, Texas
Contact:

Re: Microkernel, Memory Manager: Kernel Mode VS User Mode

Post by zeitue »

@bluemoon thank you that makes perfect sense.
I'm thinking that a of things can be split up besides just the process and memory management.
### Z++; && S++; ###
zeitue is pronounced zeɪtə
Web Site::Bit Bucket
Programming Languages: C, C++, Java, Ruby, Common Lisp, Clojure
Languages: English, zɪ̀ŋ, 日本語, maitraiuen
Post Reply