Page 1 of 1

How to start a new process in a microkernel

Posted: Wed Jul 10, 2002 11:00 pm
by Kupak
Hi !

My question is how should i implement CreateProcess() in a microkernel.
Since the fileserver is not part of the kernel,it is not clean how and where i i should load the new exe.I dont like fork()+execve() style,is there any other way ?
My idea is that CreateProcess() would allocate some kernel memory,map it into filservers adress space ,and then ask it to load the exe there.
What do you think about this ?


thx

RE:How to start a new process in a microkernel

Posted: Wed Jul 10, 2002 11:00 pm
by carbonBased
Not a bad idea, indeed.

My current task subSystem works like this (if its any help):

Task *newTask = allocate( sizeof(Task) );
TSS *newTss = allocate( sizeof(TSS) );

taskFillTSS(newTss, eip, esp);
taskCreate(Task, TSS);

taskFillTSS fills in any TSS structure with valid register contents for a new process, as well as the instruction pointer and stack pointer

taskCreate assigns this new TSS to the "Task" structure, and finds the next free GDT entry (storing it in the "Task" struct as well) and creates a selector for this TSS there.

This could be greatly simplified even more, if need be (this is just test code, really).  ESP could be omitted from taskFillTSS, and the task could be required to create its own stack at run time (this might cause problems...), and the taskCreate function could actually call taskFillTSS for you, if need be, leaving only:

taskCreate(Task *task, long eip);

The advantage here, of course, is that it isn't tied into your file server code at all... you could load a task local to your kernel (ie, a thread) or even an executable (your file system code would load an executable into memory, from the initial eip, and send it to createTask).

Jeff