
The little book about OS development - Chesco_
http://littleosbook.github.io
======
samwilliams
As someone that has just spent the last 27 months building an OS from scratch
in a University research environment (an OS that can survive catastrophic
hardware and software failure [0]), I am very impressed with the quality of
this document. I only wish I had found it previously!

OS dev can be great fun and gives you a level of understanding about how
computers actually work that is hard to gain from other sources. I have
frequently found myself using the knowledge I gained from building the OS when
working on other projects. It has been particularly useful when it comes to
understanding performance issues. I would highly recommend it to anyone that
is even remotely interested.

Other superb resources to help you get started include the OSdev wiki[1],
along with this document[2] from the University of Birmingham, UK.

[0] [http://www.hydros-project.org](http://www.hydros-project.org)

[1] [http://wiki.osdev.org/](http://wiki.osdev.org/)

[2]
[https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures...](https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-
dev.pdf)

~~~
metaobject
Your research project sounds interesting. Is there any info you can share
(white paper, etc)?

~~~
samwilliams
Thanks! At the moment, the best source of information is the talk I gave at
the Erlang User Conference 2016 [0]. Four papers and a thesis are in the
pipeline for next year, though! I will update the site once PDFs of those are
available.

[0]
[https://www.youtube.com/watch?v=9XqHiumZ02E](https://www.youtube.com/watch?v=9XqHiumZ02E)

~~~
sasas
Thanks for sharing, really enjoyed the video. Isn't it amazing that Ericsson
were achieving _nine 9 's_ (31.5 milliseconds downtime per year) [1], using
Erlang in the AXD switch back in 1998 [2].

[1]
[https://en.wikipedia.org/wiki/High_availability#Percentage_c...](https://en.wikipedia.org/wiki/High_availability#Percentage_calculation)

[2]
[https://en.wikipedia.org/wiki/Erlang_(programming_language)#...](https://en.wikipedia.org/wiki/Erlang_\(programming_language\)#History)

------
gravypod
If you want a real bang up tutorial that covers absolutely everything theory
and implementation check out Broken Thorns. You'll need to Google for it
because I'm on my phone.

Two small notes: the website is down (it's quite old and I'd be sad if the
owner has a bit of bus-syndrome), you can find it on the waybackmachine

It's the best tutorial out there for an x86 based OS

~~~
aban
Here it is:
[http://www.brokenthorn.com/Resources/OSDevIndex.html](http://www.brokenthorn.com/Resources/OSDevIndex.html)

The website's working just fine for me, but in case it doesn't work for
someone else or if it goes down again:
[https://web.archive.org/web/20161223021815/http://www.broken...](https://web.archive.org/web/20161223021815/http://www.brokenthorn.com/Resources/OSDevIndex.html)

~~~
gravypod
I feared the worst! I'll scrape the entire page and keep a local backup. It
went down for some time.

------
DAllison
Original link [pdf]:
[http://littleosbook.github.io/book.pdf](http://littleosbook.github.io/book.pdf)

HTML version: [http://littleosbook.github.io/](http://littleosbook.github.io/)

Source:
[https://github.com/littleosbook/littleosbook](https://github.com/littleosbook/littleosbook)

2015 Discussion:
[https://news.ycombinator.com/item?id=8866912](https://news.ycombinator.com/item?id=8866912)

reddit:
[https://www.reddit.com/r/programming/duplicates/2rx3wq/the_l...](https://www.reddit.com/r/programming/duplicates/2rx3wq/the_little_book_about_os_development/)

~~~
sctb
Thanks, we've updated the link from [http://feederio.com/book/37/the-little-
book-about-os-develop...](http://feederio.com/book/37/the-little-book-about-
os-development).

------
fuball63
Other than the educational value of doing so, what would be a reason to write
a brand new operating system? Obviously there is a lot to learn about existing
operating systems by coding you own, much in the way that writing a new
languages teaches you about existing languages, but what are some creative
applications of a hand made operating system?

~~~
formula1
I know Ive wanted to make changes to my own for a while. At very least default
ui, menus and shortcuts after installation. These are modtly ux changes though

Additionally theres a few features I would prefer from a security user
experience standpoint

\- symlinks are indexed anD the move or deletion of the target would trigger a
"would you like to change/delete the symlink as well?"

\- all applications run in a container

\- the application can never touch os filesystem or know about other apps but
themself and what the user allows

\- requests for hardware trigger permission dialog

\- requests for files are handled outside the container

\- shared folders are mounted to the container that the user knows are
vulnerable

\- some folders are an aggregate of the applications folders but the
application only views its own

\- deletion of an applications folder will permanently delete all if its data.
No messy installations or artifacts

\- system monitor shows cpu, memory and network usage per application

\- applications require permission to use network and outward calls can be
captured before being made

Additionally there are features from a dev standpoint

\- there is a discoverability system for modified and alternative applications

\- there is a focus on ensuring all parts of the os are easily found and
modified

\- changes to the os filesystem creates forces the user to create a virtual
machine, make changes to that then "commit" those changes in bulk

\- the user can make these patches available online along with keywords,
problem and a tutorial inorder to recreate for discoverability

\- heavy focus on user interfaces that can be reused in terminal and gui.
Applications that only are available in one or have different experiences will
be flagged as such.

But I canonly make this if I know how

~~~
Sir_Cmpwn
> symlinks are indexed anD the move or deletion of the target would trigger a
> "would you like to change/delete the symlink as well?"

Patch your coreutils. Difficulty: easy.

Most of your other needs can be addressed by making a specialized Linux distro
(difficulty: hard), rather than writing a kernel that does all of this
(difficulty: max). Build your packages to be containerized by default. I
suggest using chroot containers and writing some kind of FUSE filesystem to
mount in the container and provide controlled access to user files. You'll
also want to write or modify a Wayland compositor to suit your needs. You can
have this provide the permission prompts and similar things. Difficulty: hard,
but very much doable.

Skills to learn: Linux, thoroughly. You should be comfortable making packages,
running things in containers, and writing C before you embark on this.

You should _definitely_ build this. I'm working on something similar but my
design appeals to fewer people. Feel free to reach out to me if you have
questions with anything, email is in my profile.

~~~
formula1
I appreciate the inspirstion, I'll see to get started on it tonight. I was
looking into fuse before which inspired much pf the filesystem shinanigans

------
nayuki
About 7 years ago, I followed James Molloy's helpful tutorial for OS
development:
[http://web.archive.org/web/20160414051121/http://www.jamesmo...](http://web.archive.org/web/20160414051121/http://www.jamesmolloy.co.uk/tutorial_html/)

------
steveklabnik
This is probably a good thread to ask: one of my hobby projects is writing an
OS, but for x86-64. My next task is user mode, and while I feel pretty solid
conceptually, the details around the TSS and such I'm much shakier on. Does
anyone have a good, detailed, with-code resource on such things?

~~~
bee_vik
I'm part-way through my implementation of an x86_64 experimental OS and had to
address all the issues you're facing right now. I didn't really document my
process, but the code to get everything booted into x64 mode is there,
including setting up the TSS.

[https://github.com/beevik/MonkOS](https://github.com/beevik/MonkOS)

In particular, the bootloader:

[https://github.com/beevik/MonkOS/blob/master/boot/loader.asm](https://github.com/beevik/MonkOS/blob/master/boot/loader.asm)

~~~
steveklabnik
Neat thanks! I will check it out. It's really the context switching itself
that's the trickiest part, I think. Or all of it. To me, it feels exactly like
when I was learning about interrupts: while I was doing it, it was so tough...
but as soon as I got something working, it made perfect sense and I wondered
why I found it so hard in the first place.

~~~
bee_vik
One resource I found myself consulting over and over again was the Intel
Architecture Software Development manuals ([https://software.intel.com/en-
us/articles/intel-sdm](https://software.intel.com/en-us/articles/intel-sdm)).
They're huge and obviously a bit dry, but they had about 90% of what I needed
to know about x86 memory architecture and interrupts.

I included some other resources I consulted in the README. The OSDev wiki
([http://wiki.osdev.org/Main_Page](http://wiki.osdev.org/Main_Page)) is also
good, although I found some of it to be dated or incorrect.

Good luck on developing your OS. Even though I'm not finished, it's been an
extraordinarily valuable and educational process.

~~~
steveklabnik
Yeah, I probably need to just take a weekend day and actually read rather than
skim and look for secondary sources. The OSDev wiki's pages on this particular
topic are all kind of okay, but often aren't talking about long mode, only
protected mode, or only have bits and pieces.

Thank you! Good luck with finishing yours, as though these things are ever
finished :)

------
brian-armstrong
Does anyone have a similar guide for ARM, and specifically an Android device?
I wrote a small x86 kernel for my class project in school. Being able to run
an OS on a phone seems like a lot more fun.

~~~
mindentropy
I used to document the creation of a baremetal OS on an ARM device which uses
the S3C2440 chip here :
[http://thesoulofamachine.blogspot.in/](http://thesoulofamachine.blogspot.in/)

You can find the partially developed but documented code here:
[https://github.com/mindentropy/s3c2440-mdk](https://github.com/mindentropy/s3c2440-mdk)

The board I use is the mini2440 single board computer. You can bring up the
same on a beagle bone with some minor modifications when you are dealing with
the peripherals.

------
jesuslop
I also would add DMA (direct memory access) transfers to round the IO model.
It's important for performance and affects a quantity of devices (disk, net,
sound...).

------
DSingularity
What's the best book/resource on modern OS design and concepts? Is there one
backed by examples from Linux?

~~~
ktRolster
I would start at the OS-Dev wiki:
[http://wiki.osdev.org/Main_Page](http://wiki.osdev.org/Main_Page)

------
kuharich
Previous discussion:
[https://news.ycombinator.com/item?id=8866912](https://news.ycombinator.com/item?id=8866912)

------
dubesor
How does this differ from doing hack the kernel course stuff? Want to dip my
feet into this for better knowledge.

