Page 1 of 1

Copy on write with microkernels, put it in user or kernel?

Posted: Sat Sep 07, 2013 11:03 am
by OSwhatever
With microkernels you get the option to implement copy on write as a kernel functionality but also as a user page fault handler.

I'm a bit muddled what is the best here. There is nothing preventing you from implementing both but I'm leaning towards putting in the kernel. The reason is the user page fault handler might not own or has the source page mapped when the fault occurs. The kernel can however map whatever physical page it wants. Also, kernel copy on write is faster due to you skip one or more context switches.

What do you think, where would you have put your copy on write functionality?

Re: Copy on write with microkernels, put it in user or kerne

Posted: Sat Sep 07, 2013 11:27 am
by halofreak1990
Personally, I'd put it in the kernel. It's easier, and allows less outside manipulation.

Re: Copy on write with microkernels, put it in user or kerne

Posted: Mon Sep 09, 2013 10:38 am
by Combuster
Also, kernel copy on write is faster due to you skip one or more context switches.
Then just implement the copying in the running app to avoid the big overhead that is a task switch. After all, it has the original read-only version to start with. :wink:

Re: Copy on write with microkernels, put it in user or kerne

Posted: Mon Sep 09, 2013 2:18 pm
by OSwhatever
Combuster wrote:Then just implement the copying in the running app to avoid the big overhead that is a task switch. After all, it has the original read-only version to start with. :wink:
It is so obvious and makes sense, like I didn't see the forest because of all the trees. Unfortunately, there will be context switch due the design of the kernel but I like the approach none the less and this is probably the best solution so far. Definitely a good contender.

EDIT: There is a slight chicken and egg problem with this solution. The pager needs to be registered before starting the user program and there is no real way to determine where the pager code is located in the executable before it has started.

Re: Copy on write with microkernels, put it in user or kerne

Posted: Fri Sep 20, 2013 12:23 pm
by greyOne
OSwhatever wrote: EDIT: There is a slight chicken and egg problem with this solution. The pager needs to be registered before starting the user program and there is no real way to determine where the pager code is located in the executable before it has started.
Assuming that this is still relevant, and the way you want to solve this is as above,
Locating specific code in an executable becomes really easy if it's the only code at in a given executable section. :wink:

Re: Copy on write with microkernels, put it in user or kerne

Posted: Fri Sep 20, 2013 3:50 pm
by OSwhatever
greyOne wrote:Assuming that this is still relevant, and the way you want to solve this is as above,
Locating specific code in an executable becomes really easy if it's the only code at in a given executable section. :wink:
Yes, it is possible to locate that code in a special elf section. This might also only be done once, in the dynamic linker executable and the executable that is supposed to run does not need this special treatment.