19

What's the best operating system to study in order to write your own x86 operating system from scratch?

mudgen
  • 7,213
  • 11
  • 46
  • 46
  • 1
    I'm just curious... why would you want to do that? – intuited Mar 27 '10 at 01:22
  • 4
    Writing your own OS, even a very simple one, is a very good way to learn how they work. – David Brown Mar 27 '10 at 01:53
  • 8
    I don't know if I can give you an answer you could understand since I don't really understand your question. I don't understand how you could not want to write an operating system. We must be from opposite sides of the galaxy. – mudgen Mar 27 '10 at 02:20
  • I leant a lot from the µC/OS book it comes with source code (Proprietary, but friendly-ish licence, as far as proprietary licences go. ) for the OS, and the book gives instruction of how to port to your choice of CPU. Plus a lot of OS theory. – ctrl-alt-delor Aug 25 '17 at 18:52

9 Answers9

9

It might be difficult to comprehend the source for an entire OS all at once. The tutorials over at osdev.org have a few "bare bones" code samples to get you started.

Martin
  • 37,119
  • 15
  • 73
  • 82
9

I think Minix was created for pretty much that exact purpose.

Have fun!

Ken
  • 1,261
  • 2
  • 9
  • 7
  • 1
    Don't forget Tannenbaum's book which has the theory and the practice and was the reason Minix was written: http://www.amazon.com/Operating-Systems-Design-Implementation-Second/dp/0136386776 – msw Mar 27 '10 at 02:21
  • Even better ulix from unlixos.org Ulix was written in C and Assembler for the Intel x86 architecture Ulix has already been used three times in operating system courses at TH Nürnberg (Nuremberg Institute of Technology) – Talal Nov 12 '16 at 05:21
3

I just wrote my version of x86 kernel from scratch! (for my OS class project) and that was experience I couldn't probably describe. You can find valuable resources at above link.

Chintan Parikh
  • 609
  • 1
  • 5
  • 14
2

For my OS class in college we used the Nachos OS Project and implemented that. I did the C++ version, however I think there is also a Java port of this as well. I remember it being very interesting and learning a great deal, even though it was a lot of work.

cpalmer
  • 1,107
  • 6
  • 10
  • Nuts! I was going to say NachOS - we used it at UWaterloo for our OS class. Lemme just say - any system where kernel space is little-endian and user space is big-endian is a bit of a mindfsck. – MikeyB Mar 27 '10 at 02:13
2

It all depends on how you want your Operating System to function, if you want a microkernel you should probably study Minix 3, or if you want a monolithic kernel the current linux kernel is a good place to start from (HINT: look in arch/x86/boot, there is some very interesting code in there). However I personally think that you should read through the Intel and AMD manuals, and then do a bit of reading on the osdev.org forums and wiki. They have plenty of code to study, and are generally helpful towards newbies.

Joe D
  • 2,855
  • 2
  • 31
  • 25
1

Honestly, you should probably not start with an x86 architecture, or even operating systems but maybe something like an 8-bit starter kit, like a basic Fox11 development kit. In college, I wrote my first (and only) OS in Assembly for an M68HC11 processor (the one in the kit).

If you really want to build your own OS from scratch, you've got a long road ahead of you.

Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194
1

I think best way to read many different operating system sources, definitely osdev barebone tutorials, whitepapers on OS research and documentation on your target hardware.

I personally would recommend looking at l4-ka pistachio kernel, written in pretty darn good C++. There are also multiple smaller projects definitely worth checking out, like jimix or pedigree.

Best to stick around osdev forums and wiki - there is a lot of information there already answered - see http://forum.osdev.org and http://wiki.osdev.org

berkus
  • 1,552
  • 12
  • 16
0

I read this article a while back. You might find it interesting. This guy wrote MINIX back in the day for the very purpose of teaching OS concepts. So it would probably be a good simple OS to study. http://www.cs.vu.nl/~ast/brown/

However, as Martin and Cory mentioned, it's a big chunk to chew.

sonrael
  • 11
  • 1
0

There is not much point in studying obsolete OS's which is pretty much all current OS's as they tend to have long lives. Have a look at some fresh ideas (although based on tried and true) like Singularity

TFD
  • 23,890
  • 2
  • 34
  • 51