
How to Write an Operating System - superberliner
http://www.acm.uiuc.edu/sigops/roll_your_own/intro.html
======
kenjackson
Either I'm missing something or this tutorial is seriously lacking.

I'd much recommend Tannenbeum's classic text that covers implementing Minix:
[http://www.amazon.com/Operating-Systems-Implementation-
Prent...](http://www.amazon.com/Operating-Systems-Implementation-Prentice-
Hall-Software/dp/0136374069)

But since this text is rather old, it doesn't have some of the later
developments in OS. So for that additional material, I'd recommend his latest
book to have at your side: [http://www.amazon.com/Modern-Operating-Systems-
Andrew-Tanenb...](http://www.amazon.com/Modern-Operating-Systems-Andrew-
Tanenbaum/dp/0136006639/ref=pd_sim_b_1)

~~~
michael_dorfman
Actually, I'd recommend the latest version of OSDI, which is fairly recent,
and contains the complete source for MINIX3 (in text form, and on CD):
[http://www.amazon.com/Operating-Systems-Design-
Implementatio...](http://www.amazon.com/Operating-Systems-Design-
Implementation-3rd/dp/0131429388)

~~~
gruseom
So Tanenbaum has two OS textbooks in print? How different are they? Why read
one rather than the other?

~~~
michael_dorfman
OSDI is "the MINIX book". It shows, about as much detail as possible, how a
microkernel-based OS is written, down to the actual (complete) source code.

Modern Operating Systems, on the other hand, is a bit higher level (but still
fairly nitty-gritty) and examines two monolithic kernels (Linux/Unix and
Windows) as case studies.

------
shoesfullofdust
Since each chapter does not link to the next (the zeroeth one does, but not
the others), here's a link to the index:
<http://www.acm.uiuc.edu/sigops/roll_your_own/>

------
nivertech
I used XINU to study OS course: <http://en.wikipedia.org/wiki/Xinu>

Xinu is a small, elegant, multitasking Operating System supporting the
following features:

    
    
        * Concurrent Processing
        * Message Passing
        * Ports
        * Semaphores
        * Memory Management
        * Buffer Pools
        * Uniform Device I/O
        * Shell
        * Tcl
        * TCP/IP
    

Xinu was originally designed as a vehicle for teaching Operating System design
concepts and is used by many educational institutions for this purpose. Later
versions supported TCP/IP, these versions are often used in Data
Communications courses.

~~~
xulescu
Interesting project, but it's name sounds too much like Xenu:
<http://en.wikipedia.org/wiki/Xenu> .

~~~
crazydiamond
Actually, it's Unix backwards, but surely you knew that.

~~~
ralph
As well as being Unix backwards, it's also a recursive acronym; Xinu is not
Unix.

------
dharmatech
Some hobby OSes:

<http://f2.fasm4u.net/hyos.html>

<http://softwarewizard.dk/mojo>

<http://mikeos.berlios.de>

<http://www.ctpp.co.uk/chaos>

<http://www.returninfinity.com/baremetal.html>

<http://mythago.net/enthflux.html>

A kernel development tutorial:

<http://www.jamesmolloy.co.uk/tutorial_html/index.html>

~~~
SkyMarshal
Add Menuet, the OS written in assembly, to that list too:

<http://www.menuetos.net/>

------
abless
Some good tutorials can be found at <http://www.osdever.net/tutorials/index>
\- these are generally more hands-on than academic textbooks. Also, feel free
to have a look at <http://flick.cvs.sourceforge.net/flick/src/>, my attempt at
writing an OS (long time ago, now); the code is clear enough to give you a
rough idea on how to get started.

------
MaysonL
For another look at OS design and implementation, try _Project Oberon_.
Beautifully clean design, if somewhat dated by hardware advances since the
80s.

<http://www-old.oberon.ethz.ch/WirthPubl/ProjectOberon.pdf>

------
donaq
See, this is why I dream of making FU money. So I can spend all my time doing
stuff like that.

~~~
hxr
Makes me wonder, can I make that money doing stuff like this? I know systems
research is irrelevant and all that (Rob Pike)... AFAIK the last successful
operating systems startup was VMware (is that true?). Does the world have
place for more OS startups these days?

~~~
kragen
Systems software research was irrelevant ten years ago when Rob wrote that.
Thanks in part to his efforts, there's a great deal of relevant systems
software research now: Golang, MapReduce, Hadoop, Tahoe-LAFS, Caja, Chrome
(the browser), LuaJIT, seL4, Capsicum, the CLR, HotSpot, V8, Nitro,
Tracemonkey, GFS, Sawzall, Pig, Redis, Puppet, Chef, Tor, HTML5, ...

Most of this, but not all, comes from the traditional academic and industrial-
lab research context.

~~~
jff
How is Chrome "systems software"? It's just a damn web browser.

~~~
kragen
In <http://doc.cat-v.org/bell_labs/utah2000/> (the point of reference for this
discussion), "systems" is defined as "Operating systems, networking,
languages; the things that connect programs together." Examples of what he's
talking about from other parts of those slides include:

> By contrast, a new language or OS can make the machine feel different, give
> excitement, novelty. But today that's done by a cool Web site or a higher
> CPU clock rate or some cute little device that should be a computer but
> isn't.

> Work on how systems behave and work, not just how they compare. Concentrate
> on interfaces and architecture, not just engineering.

> Only one GUI has ever been seriously tried, and its best ideas date from the
> 1970s. (In some ways, it's been getting worse; today the screen is covered
> with confusing little pictures.) Surely there are other possibilities.
> (Linux's interface isn't even as good as Windows!)

> There has been much talk about component architectures but only one true
> success: Unix pipes. It should be possible to build interactive and
> distributed applications from piece parts.

Chrome is an environment for running AJAX web applications and enabling them
to talk to each other; among other services, it provides a graphical user
interface toolkit (DHTML), a SQL database (SQLite), security mechanism and
policy (via tab-per-process, the same-origin policy, incognito mode, and
restrictions in the JS engine), a JIT compiler for a language, and process
management (both at the user level, with its process viewer, and at the
language level with Web Workers). It has a component architecture built in;
several of them, actually: iframes, plugins, JSONP. It is possible in Chrome
to build an interactive application from "piece parts"; this is currently
called a "mashup".

So Chrome is right in the center of the issues Pike's talk was talking about.
Much of this, of course, is made of ideas that don't come originally from
Chrome; but Chrome is on the cutting edge of making new stuff possible.

------
djcapelis
My friend was part of a group of students who decided to write XOmB. They just
apparently decided it would be a neat project, now it's a pretty cool
exokernel: <http://xomb.net/index.php?title=Main_Page>

~~~
steveklabnik
Hey, thanks for the shout-out.

Not only are we working on XOmB, (pronounced 'zombie') but we extracted all of
the stuff "from power on 'till kmain" and called it XOmB Bare Bones, so that
other people who want to write kernels in D don't have to worry about that
ugliness: <http://wiki.xomb.org/index.php?title=XOmB_Bare_Bones>

~~~
djcapelis
That is great to hear. I've heard a few stories on how painful that stuff was
to track down and write. Bring up always sucks. This sounds like an excellent
way for people to dig into writing kernels without forcing people to write all
the bootup code before they can do anything.

How do you do device handoff? Are people restricted to an exokernel model or
can they handoff to a macrokernel kexec style?

(VMware used to use the Linux kernel to take care of init before they wrote it
themselves, so there's definitely a need for this type of thing, even beyond
hobbyist.)

~~~
steveklabnik
In classic exokernel fashion... you have a choice! Someone can write a libos
to handle that stuff however they'd like, or you can just go do the work
yourself.

------
nivertech
I implemented my own timesharing kernel in C and little inline x86 assembler.

Main ideas:

1\. Write context switch routine, which will require a little inline x86
assembler code.

2\. Map it to timer interrupt.

3\. Use C setjmp and longjmp to switch context.

------
ja30278
Surprised not to see "Design and Implementation of the FreeBSD Operation
System" mentioned yet ([http://www.amazon.com/Design-Implementation-FreeBSD-
Operatin...](http://www.amazon.com/Design-Implementation-FreeBSD-Operating-
System/dp/0201702452)).

McKusick's 'Kernel Internals' class is based on this, and is well worth your
time (though it's a bit pricey to purchase the videos on your own:
<https://www.mckusick.com/courses/advorderform.html>)

------
steveklabnik
<http://osdev.org> is another great resource and small community for people
trying to make hobby OSes.

------
philwelch
I took a class like this once except instead of i386 we implemented on 16-bit
x86 so we had to fiddle with the stack and registers manually to switch kernel
and user mode, or to switch processes. It was great fun despite a few
eccentricities.

------
krmboya
Cool

~~~
PidGin128
The comment doesn't meet the guidelines, certainly.

However, a lesson could have been gleaned from zero points. There is no need
to dig a grave.

