What a kernel consists of
Posted: Mon Aug 11, 2003 1:45 pm
I was just wondering what a kernel program would consist of. Like what do you put in the program?
-MeLkOr
-MeLkOr
The Place to Start for Operating System Developers
http://f.osdev.org/
I learned from this one.MeLkOr wrote:Does anyone possibily have sample kernel that was written in C?
Once again, C is fine! Most operating system kernels tend to be written in C (although you must use assembly language once or twice).Is it possible to write a whole kernel in C or do you have to use another language?
Well, I guess it would fulfil certain definitions of 'kernel'. But that's not what this board -- and OS development in general -- is about. OS development is about running the whole machine and doing something useful with it, not reinventing CMD.EXE.So would it be considdered a kernel if i had a little command line type thing that would perform operations if you typed certin commands? Even if it was still a windows based program?
What you described is more like the shell of the OS. Actually, the kernel is the dark magic that performs operations behind the shell.MeLkOr wrote: So would it be considdered a kernel if i had a little command line type thing that would perform operations if you typed certin commands? Even if it was still a windows based program?
-MeLkOr
Code: Select all
#include <os.h>
main() {
char buffer[LONG_ENOUGH];
int errcode;
while(fileReadLine(STDIN_FILE_HANDLE,buffer)) {
if (strcpy(buffer,"exit")!=0) {
if (fileExists("/bin",buffer)
errcode=exec("/bin",buffer);
else fileWriteLine(STDOUT_FILE_HANDLE,"invalid command. try 'help'");
if (errcode) fileWriteLine(STDOUT_FILE_HANDLE,errmsg[errcode]);
fileWriteLine(STDOUT_FILE_HANDLE,"$>");
} else exit(0);
}
}