How to build an OS


13 posts
by stuporhero » Mon Sep 12, 2011 3:25 pm
First thing I'll be doing with the RaspberryPi is attempting this tutorial http://www.jamesmolloy.co.uk/t.....index.html, porting to accommodate the ARM chip as I go along...

I thought I'd leave this here for anyone interested in the same :)
Posts: 125
Joined: Fri Aug 19, 2011 2:02 pm
by ShiftPlusOne » Wed Sep 14, 2011 3:37 am
Good luck, an OS is one of the most complicated piece of software you can write.
Forum Moderator
Forum Moderator
Posts: 2029
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy
by stuporhero » Wed Sep 14, 2011 6:26 am
Indeed, that and game engines I believe...?
Posts: 125
Joined: Fri Aug 19, 2011 2:02 pm
by NimbyDagda » Thu Sep 15, 2011 2:16 pm
After an Operating System, building compilers is the next hardest thing you can do, followed by designing a language. So I suggest someone attempt to design a new language, with a new compiler on a custom operating system if they want a real challenge :P

Also slightly more on topic, there is quite a lot you would have to change from that tutorial to make it work for arm. The entire interrupt architecture just for starters.

You might find the osdev wiki ARM category slightly helpful, although it is far from comprehensive
http://wiki.osdev.org/ARM_Overview
Posts: 6
Joined: Thu Sep 08, 2011 11:35 am
by jamesh » Thu Sep 15, 2011 3:09 pm
Quote from NimbyDagda on September 15, 2011, 15:16
After an Operating System, building compilers is the next hardest thing you can do, followed by designing a language. So I suggest someone attempt to design a new language, with a new compiler on a custom operating system if they want a real challenge :P

Also slightly more on topic, there is quite a lot you would have to change from that tutorial to make it work for arm. The entire interrupt architecture just for starters.

You might find the osdev wiki ARM category slightly helpful, although it is far from comprehensive
http://wiki.osdev.org/ARM_Overview


I'd say writing a compiler was more complicated than an OS...for the life of me I cannot see how you write an optimising compiler, but I do get most parts of OS design.
Volunteer at the Raspberry Pi Foundation, helper at Picademy September and October 2014.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 12113
Joined: Sat Jul 30, 2011 7:41 pm
by liz » Thu Sep 15, 2011 3:19 pm
Quote from jamesh on September 15, 2011, 16:09
Quote from NimbyDagda on September 15, 2011, 15:16
After an Operating System, building compilers is the next hardest thing you can do, followed by designing a language. So I suggest someone attempt to design a new language, with a new compiler on a custom operating system if they want a real challenge :P

Also slightly more on topic, there is quite a lot you would have to change from that tutorial to make it work for arm. The entire interrupt architecture just for starters.

You might find the osdev wiki ARM category slightly helpful, although it is far from comprehensive
http://wiki.osdev.org/ARM_Overview


I'd say writing a compiler was more complicated than an OS...for the life of me I cannot see how you write an optimising compiler, but I do get most parts of OS design.


Go ask Eben - optimising compilers was what his PhD was about. I don't understand a word of the damn thing.
--
Head of Comms, Raspberry Pi Foundation
User avatar
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 4141
Joined: Thu Jul 28, 2011 7:22 pm
by stuporhero » Thu Sep 15, 2011 3:19 pm
Hi Nimby, I've taken a read through the osdev stuff and it's great - Pulling off an OS is going to depend on studying the source of the working Linux for RaspberryPi and studying the code that handle the important parts as listed on the OSDev wiki. I only got as far as understanding the architecture of the Spectrum +2A before my schooling was over and guitars/drinking etc took over! I'd like to get back into a position like that again with ARM architecture...

@Eben: GOD! 8-)
Posts: 125
Joined: Fri Aug 19, 2011 2:02 pm
by ats » Thu Sep 15, 2011 3:23 pm
If you're interested in learning about writing operating systems, you might want to look at Pintos. It's a bare-bones OS that is designed for teaching, so there are several projects that involve adding various features to it, along with test suites to verify they are working correctly (http://www.scs.stanford.edu/10.....intos.html).

It's for x86 systems so it won't run unmodified on Raspberry Pi, but it is a good way to learn about some of the functions an OS provides before attempting to write your own.
Posts: 6
Joined: Fri Aug 26, 2011 2:02 pm
by stuporhero » Thu Sep 15, 2011 3:30 pm
Thanks for the link :D
Posts: 125
Joined: Fri Aug 19, 2011 2:02 pm
by MarkSmith » Sat Sep 17, 2011 5:11 pm
You may want to take a look at RetroBSD 2.11 http://retrobsd.org . It would require work but not as much as starting from the bottom up.
Posts: 29
Joined: Sat Sep 17, 2011 3:58 pm
by anndra » Sat Sep 17, 2011 6:57 pm
There is a chapter on developing a basic operating system for ARM in:

Sloss, A. et al.
2004 ARM system developer's guide: designing and optimizing system software
San Francisco: Morgan Kaufmann Publishers

See:
http://books.google.com/books/.....KUkDQE17QC

The code for the OS is at http://www.elsevierdirect.com/.....1558608740

Should be a good place to start.
Posts: 5
Joined: Mon Aug 29, 2011 3:42 pm
by Gert van Loo » Sat Sep 17, 2011 6:58 pm
I think it depends on what your OS needs to do. In the old days every programmer wanted to build at least once a multitasking tiny OS. There must be thousands of them. Many years ago I wrote mine: tiny program which could just run concurrent tasks and had basic I/O over a serial port. Underlying structure was queues, messages queues, timer queues etc. (I even had calls to hook into queues) Everything was in C except the final task switch code (store-multiple, load multiple) Was that an OS? Maybe, maybe not. But it was fun.
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2096
Joined: Tue Aug 02, 2011 7:27 am
by tufty » Sat Sep 17, 2011 7:09 pm
Quote from jamesh on September 15, 2011, 16:09I'd say writing a compiler was more complicated than an OS...for the life of me I cannot see how you write an optimising compiler

A good start is reading Christian Queinnec's "LiSP In Small Pieces" (this covers compiling Lisp to C, which is a good start), followed by Gerald Sussmann's "Structure and Interpretation of Computer Programs" (which covers compiling Scheme to an abstract register machine. Once you've digested that, you might want to get into Appel's "Compiling with Continuations" which starts getting into optimisations. Guy Steele's "lambda papers" are worth a look, too, particularly the stuff on RABBIT.

You're right, though. It's pretty hairy stuff.
Posts: 1371
Joined: Sun Sep 11, 2011 2:32 pm