Sign in to follow this  
M2tM

Build OS from scratch

Recommended Posts

If I were to aim at building a rediculously bare-bones OS in C++ could anyone point me at some resources I can use to look up how to approach this? I am interested in this project for academic purposes so please don't try to dissuade me, I know I won't make a better OS than existing ones, I just want to know -how- to do it.

Share this post


Link to post
Share on other sites
Hi,

The best pointer I can give you is sos.enix.org. Their website is in french or
english if you prefer. They wrote about 10 articles for the French Linux
Magazine explaining the inner workings of an OS. their OS implements several
ideas found in the Linux 2.4.3 kernel and is pretty easy to follow(comes
along with a PDF and source code for each lesson).

Here you have the state of the tutorials: http://sos.enix.org/en/MainPage

Ohh I forgot, SOS is implemented in C and ASM, but you can manage to do it
in C++.

Other resources include: www.osdever.net

Have fun

Share this post


Link to post
Share on other sites
While the high level stuff can be written in C++, you'll still have to deal with asm at some point - the startup code, system init and OS core init is impossible to write in a high level language, unless the high level language is able to bootstrap itself (which is not the case of C++).

Regards,

Share this post


Link to post
Share on other sites
For moving a little higher level, above the "how to write an OS", there is also the question of good OS design. Each OS in the world needs to do the same things to interact with the hardware - access the BIOS, access the hardware, etc. But then are the differences - how they abstract the ideas, how they expose their features can vary wildly.

For that part, I highly recommend you look at the most wonderfull OS I've ever had the pleasure of working on ... BeOS. There was a book "Be Developer's Guide" which covers the main elements of the API. 3 things make BeOS distinct - 1) It is built from the ground up for pervasive multithreading and mutliprocessor leveraging (2 procs run the OS an average of 98% faster than 1 proc, thats better than any other general purpose OS), 2) It was built for the multimedia world, with an amazing media kit and a very responsive scheduler and timers, 3) It's primary programming API is actually well designed Object-Oriented C++, not structured C.

Whatever you choose to do, best of luck to you.

Share this post


Link to post
Share on other sites
And don't forget you'll need to write all the code (C, ASM, whatever) that allows C++'s higher-level features to run. Constructors/destructors for global objects needs support code (not much), as does RTTI. From memory there's a tutorial about how to do that on one of the links provided. In fact, I'll search for it now... and here it is.

Yeah, it's compiler specific. Bummer, ey?

Share this post


Link to post
Share on other sites
Quote:
Original post by Ravuya
See if you can track down a university class or Tannenbaum's books.

You're probably best to find decent books on this than scrabbling around on messageboards: most of the stuff I've seen is incomplete at best.


I'm in cs 330 which is "Introduction to Operating Systems" in this class we will write a simulation of a portion of an Operating System... But it doesn't sound like we'll learn anything in detail about how to actually create a bootable OS... Most likely we'll build a filesystem or something on top of an existing OS... The course has just started, so it's early to say much, I just want to come out of it with a real understanding of how to make a real bootable OS which is why I'm looking into this.

Thanks again guys.

I'm not sure if I have the time required to get a bootable command prompt between this and my other courses and so I may not be able to show you the product of the research... We'll see. It's kind of a project I wouldn't continue beyond this course anyway as there exist many operating systems already and they are done better than anything I would come up with. I'd rather invest time in my painting program I'm working on... But this is still of interest. We'll see what happens.

Share this post


Link to post
Share on other sites
Quote:
Original post by M2tM
Quote:
Original post by Ravuya
See if you can track down a university class or Tannenbaum's books.

You're probably best to find decent books on this than scrabbling around on messageboards: most of the stuff I've seen is incomplete at best.


I'm in cs 330 which is "Introduction to Operating Systems" in this class we will write a simulation of a portion of an Operating System... But it doesn't sound like we'll learn anything in detail about how to actually create a bootable OS... Most likely we'll build a filesystem or something on top of an existing OS... The course has just started, so it's early to say much, I just want to come out of it with a real understanding of how to make a real bootable OS which is why I'm looking into this.

Thanks again guys.

I'm not sure if I have the time required to get a bootable command prompt between this and my other courses and so I may not be able to show you the product of the research... We'll see. It's kind of a project I wouldn't continue beyond this course anyway as there exist many operating systems already and they are done better than anything I would come up with. I'd rather invest time in my painting program I'm working on... But this is still of interest. We'll see what happens.


I'm also in an OS course this semester (about 1/2 the way through it), and we're using Tanenbaum's book Modern Operating Systems (2nd Edition) as our text.

There's no way in hell you're writing an operating system. Not even a command line one. There's just way too much for a uni project. As a hobby project, a command-line OS is not an unreachable goal, but for uni marking, it's too big a project. They need to makr whether you're right or not, remember, [grin].

Share this post


Link to post
Share on other sites
Quote:

There's no way in hell you're writing an operating system. Not even a command line one. There's just way too much for a uni project.


Does OS 161/System 161 count? I managed to get through most of that in my university course.
It is a "simulated" OS, in that it runs on a fake MIPS machine, but the OS doesn't know it is in a sim,
and there is no tie to it from the OS. So, i'd say it is a bare-bones commandline OS.

I will note that there is a lot of base code that you get to use, but there is a lot
you have to implement on your own.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this