Build !!! kernel !!!

K

kristian

Hi folks,
Do you ever tried to build your own kernel? What type of programming
language did you use?
I've heard there is a way to do that in C but I don't know HOW!
If is it possible, can you recommend me some pages, documents or
anything what is about it?

Thanks
 
W

W Marsh

Hi folks,
Do you ever tried to build your own kernel? What type of programming
language did you use?
I've heard there is a way to do that in C but I don't know HOW!
If is it possible, can you recommend me some pages, documents or
anything what is about it?

Thanks

You need to do this:

makeThisProgramIntoAnOS("please");
 
D

Diomidis Spinellis

Do you ever tried to build your own kernel? What type of programming
language did you use?
I've heard there is a way to do that in C but I don't know HOW!
If is it possible, can you recommend me some pages, documents or
anything what is about it?

Operating systems are nowadays typically written in C, with some tiny
sprinkling of assembly code for very low level functionality (e.g.
initializing the processor's state). Check out the following books:

- Andrew S. Tanenbaum. Operating Systems: Design and Implementation.
Third Edition. Prentice Hall, Englewood Cliffs, NJ, 2006.
(contains the complete source code for the Minix operating system)

- John Lions. Lions' Commentary on Unix 6th Edition with Source Code.
Annabooks, Poway, CA, 1996.
(contains the complete source code of the 6th Edition Unix - this is
more of historical interest).

- Maurice J. Bach. The Design of the UNIX Operating System. Prentice
Hall, Englewood Cliffs, NJ, 1986.
(Discusses the design of the AT&T version of Unix)

- Marshall Kirk McKusick and George V. Neville-Neil. The Design and
Implementation of the FreeBSD Operating System. Addison-Wesley, Reading,
MA, 2004.

You can also freely download the source code for the Linux, FreeBSD,
NetBSD, and OpenBSD kernels.
 
M

Manuel Tobias Schiller

Do you ever tried to build your own kernel? What type of programming
language did you use?
I've heard there is a way to do that in C but I don't know HOW!
If is it possible, can you recommend me some pages, documents or
anything what is about it?

[ ... snip ...]

You can also freely download the source code for the Linux, FreeBSD,
NetBSD, and OpenBSD kernels.
AFAIK, the Minix sources are also freely available, so if one wants to
learn from an OS which is still relatively easy to grasp because it's
small, Minix might be an option.

Regards

Manuel
 
R

Rod Pemberton

Hi folks,
Do you ever tried to build your own kernel?

Yes. IA-32 Ring 0.
What type of programming
language did you use?

C with some inline assembly and one pure assembly file in NASM.
Specifically, the kernel compiles with two DOS compilers DJGPP and
OpenWatcom 1.3. I currently have roughly 2500 lines of C and 360 lines of
inline assembly (duplicated for each compiler).
I've heard there is a way to do that in C

Yes. But, it is difficult. The C libraries of your compiler are usually
built upon OS functions. In other words, most OS's are written _before_ the
C compiler _usually_ in assembler. Basically, this means that if you try to
write an OS in C many C library functions will be incomplete due to the
missing functions calls of the original OS. Critically important things
like reading the keyboard controller, file I/O, interrupt routines will all
need to be provide by you. Usually, the memory, string, and character
library functions are clean, due to their simplicity. Also, the functions
of a C compiler: creating constants, variables, flow control structures
(including if's, procedures, etc), and arithmetic and pointer operations,
are usually free from the original OS function calls.
but I don't know HOW!

You'll need a way to take control of your computer. This is usually done
with a bootloader and it's API (such as Grub). It can also be done via
other special transfer mechanisms from certain environments (i.e., DOS
DPMI).
If is it possible, can you recommend me some pages, documents or
anything what is about it?

I would start by studying other OS's written in C on the web. Freedos-32 is
written in C. I personally don't think it's method of implementation is
spectactular. But, it works. Another place to start are some of the sample
OS's. These have been written by people like Chris Giese, Alexei Frounze,
John Fine, etc. There are dozens of tutorial OS's such as Wild Boar Scafa,
Thix, Topsy, Bran, Visopsys, Mach, Shawn, etc...


Rod Pemberton
 
R

Richard G. Riley

Do you mean an OS or a kernel? Or the OS kernel?
Yes. IA-32 Ring 0.


C with some inline assembly and one pure assembly file in NASM.
Specifically, the kernel compiles with two DOS compilers DJGPP and
OpenWatcom 1.3. I currently have roughly 2500 lines of C and 360 lines of
inline assembly (duplicated for each compiler).


Yes. But, it is difficult. The C libraries of your compiler are usually
built upon OS functions. In other words, most OS's are written _before_ the
C compiler _usually_ in assembler. Basically, this means that if
you try to

The core IO routines might be in assembler but the
rest is generally a C level above. In other words most of the OS is in
C : a tiny subpart would be in HW specific assembler IMO.
write an OS in C many C library functions will be incomplete due to the
missing functions calls of the original OS. Critically important things
like reading the keyboard controller, file I/O, interrupt routines will all
need to be provide by you. Usually, the memory, string, and character
library functions are clean, due to their simplicity. Also, the functions
of a C compiler: creating constants, variables, flow control structures
(including if's, procedures, etc), and arithmetic and pointer operations,
are usually free from the original OS function calls.


You'll need a way to take control of your computer. This is usually done
with a bootloader and it's API (such as Grub). It can also be done via
other special transfer mechanisms from certain environments (i.e., DOS
DPMI).


I would start by studying other OS's written in C on the web. Freedos-32 is
written in C. I personally don't think it's method of implementation is
spectactular. But, it works. Another place to start are some of the sample
OS's. These have been written by people like Chris Giese, Alexei Frounze,
John Fine, etc. There are dozens of tutorial OS's such as Wild Boar Scafa,
Thix, Topsy, Bran, Visopsys, Mach, Shawn, etc...

The most obvious is Linux : it is supported and works. And is written
mostly in C.
 
K

Kevin Handy

Richard said:
The most obvious is Linux : it is supported and works. And is written
mostly in C.

Some other OS's freely available with source (and written mostly
in C) are NetBSD, OpenBSD, FreeBSD, some old versions of AT&T
unix, FreeDOS, etc...

Then there are some oddball items like Wine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,177
Messages
2,570,954
Members
47,507
Latest member
codeguru31

Latest Threads

Top