Writing an operating system in C++

Viewed 41230

what is a way to create a my own operating system using c++. I have been created boot loader (using nasm,qemu) but I haven't knowledge to add an kernel to this boot loader.

7 Answers

Be careful, C++ is pretty heavyweight for an OS kernel.

  • There are services like exceptions that you'll have to support with a runtime library.
  • It won't feel like C++ until you add a heap.
  • Kernels are very sensitive to where objects are allocated; the one-heap model usually used in C++ isn't really suitable.
  • Coupling APIs to data structures is a bad idea. BeOS had problems with this. You need to hide the size of your internal structures from users, and that means jumping through hoops (Pimpl, private constructor, virtual functions) when APIs are member functions.

It sounds like you're already further along than most, so keep asking questions and you'll probably end up somewhere nice! :vD

Also to add, This book by Tanenbaum, where he explains the implementation details of minix.

You may consider looking at MINIX which is a small operating system for x86 systems. It was originally designed as a teaching project and has evolved into something that's intended to be useful in the real world.

you can take a look at minix 3 source code. it's a very simple os, created with the purpose of understand how operating system works.

you can also study all the tanenbaum book about os. they are all very complete and I remember that one book has the complete source of minix attached and commented

I am not familiar with details, but by my knowledge BeOS was written in C++. Sources should be freeley available as well as the documentation.

For a C++ operating system, you may want to look at NewOS or UnixLite.

Related