Page 1 of 1

Separating the kernel

Posted: Wed Jun 01, 2011 5:23 pm
by BASICFreak
OK, I have been working on a very "simple" OS for a wile now, currently I have a small "command prompt" but everything so far is in the kernel.

I am looking for documentation, information, or examples of how to get the "command prompt" or any "program" in general separated from the kernel

I want the kernel to handle all the keyboard input and video output, but I have not been able to find any information on how to get a "program" to communicate with the kernel rather than rewriting the "driver" per "program".

Any information is greatly appreciated.

Thanks in advance,
BASICFreak

I am sorry if this question has been asked before, I searched the WiKi but I think I just did not know what terms to look for. I am still very new to OS development.

Re: Separating the kernel

Posted: Wed Jun 01, 2011 5:33 pm
by piranha
Well, the programs would be executable files that the kernel loads and runs. The programs interface with the kernel by use of system calls (its on the wiki).

-JL

Re: Separating the kernel

Posted: Wed Jun 01, 2011 5:34 pm
by gerryg400
You need a kernel/system API. For example, in the Posix world, your 'shell' would be a user-space program. It will do something like this.

Code: Select all

fdin = open("/dev/console", ...);  // or /dev/kbd etc.
fdout = open("/dev/console", ...);   // or /dev/screen  etc.

while (1) {

    char ch;

    write(fdout, "$ ", 2);

    read(fdin, &ch, 1);

    switch (ch) {
       // process text input etc.
    }
}
At the 'system/kernel' interface you need to implement open/read/write etc. for each device type.

I should stress that Posix is just one OS interface. You can make your own.