
How to write a simple operating system - ingve
http://mikeos.sourceforge.net/write-your-own-os.html
======
roryisok
I'm not sure why, but whenever I see a link pointing to sourceforge my instant
gut reaction is that it'll be a decade+ aged code that doesn't work properly
anymore. I always avoid sourceforge when searching for solutions. I don't know
why I have this bias

~~~
lacampbell
Which is sad, that active open source projects are now synonymous with a
single companies service built around a single VCS.

~~~
yladiz
It's not necessarily centered around Github (although many open source
projects are hosted there) -- there's also Gitlab, Bitbucket. The bigger
reason that there's a reaction against SourceForge is that it has a long
history of deceptive packaging practices, shady ads, and injecting malware
into the packages they were distributing. Now SourceForge is under new, better
management, but it's hard to kick that reputation.

------
krat0sprakhar
There's also "How to Make a Computer Operating System in C/C++" in a nice,
readable Gitbook: [https://samypesse.gitbooks.io/how-to-create-an-operating-
sys...](https://samypesse.gitbooks.io/how-to-create-an-operating-
system/content/)

~~~
cr0sh
Unfortunately, nothing more seems to be written after the "Memory management:
physical and virtual" chapter...?

[https://github.com/SamyPesse/How-to-Make-a-Computer-
Operatin...](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-
System)

Disappointing...

------
wonderous
(2014) should be in the title.

[https://web.archive.org/web/20140719115200/http://mikeos.sou...](https://web.archive.org/web/20140719115200/http://mikeos.sourceforge.net/write-
your-own-os.html)

Maybe even (2011):
[https://news.ycombinator.com/item?id=2100115](https://news.ycombinator.com/item?id=2100115)

------
rbanffy
If one is going to use an emulator to test an OS, why be confined to the x86
ISA and all the historic warts of the PC?

Design a decent computer first, then write an OS for it.

~~~
nickpsecurity
Or just use a simple, stack machine. Or a RISC CPU. Preferrably on an emulator
or FPGA already. Oberon did this.

~~~
bogomipz
I would like to hear more about Oberon OS running on an emulator. Might you
have a link, this sounds interesting?

~~~
Someone
I think the OP, when saying _" Preferrably on an emulator or FPGA already.
Oberon did this.”_ meant that Oberon (second edition; the first one ran on a
NS32032) ran on a FPGA
([https://lists.inf.ethz.ch/pipermail/oberon/2013/006922.html](https://lists.inf.ethz.ch/pipermail/oberon/2013/006922.html),
[https://www.inf.ethz.ch/personal/wirth/ProjectOberon/PO.Comp...](https://www.inf.ethz.ch/personal/wirth/ProjectOberon/PO.Computer.pdf))

~~~
bogomipz
I see that makes sense, thanks for the clarification and the links. The more I
hear about Oberon the more intrigued I am. Thanks for the links.

------
alxmdev
Well-written primer, so cool to see something complex reduced to its simplest
form that captures the essence.

Funny to read how PC memory can be "millions of bytes on modern machines". To
be fair, I was using a computer with only 128MB as recently as 7 years ago :-)

~~~
analognoise
To be fair, that's still millions of bytes.

~~~
H4CK3RM4N
But, like, less millions.

------
drewg123
Awesome. We need resources like this to get people into low level programming.

The best class I ever took when I was an undergrad was a class where we built
our own OS for a Data General Aviion workstation. Our systems staff was
already under contract to help port 4.3BSD to the Aviion, and they had tons of
test hardware and docs. So one of the group taught an OS class where whey
basically turned us loose with a cross-toolchain and a manual and let us hack
all semester. I think by the time we were done, we had something that booted
and interacted with a very basic shell (but could not fork, no multi-tasking,
no mem prot, etc).

If it were not for this class, I think the more theoretical OS class that I
took later in grad school (all dreadfully boring queueing theory style stuff)
would have turned me off to doing OS work. Instead, I've had a career doing
lots of low-level stuff (drivers, OS ports to new CPUs, network stack
improvements, etc).

------
dang
Discussed in 2011:
[https://news.ycombinator.com/item?id=2100115](https://news.ycombinator.com/item?id=2100115)

------
partycoder
Some resources for writing OSes:

\- Andrew Tannenbaum's MINIX, and his Operating system books

\- The OSDev wiki: [http://wiki.osdev.org](http://wiki.osdev.org)

------
giancarlostoro
Anyone know any such resources for the Raspberry Pi 3? Only found some for the
first Raspberry Pi

~~~
laumars
Writing an OS for the Raspberry Pi is harder work that it should be because of
the Broadcom SoC. It's a closed, proprietary chip that does a lot of the heavy
lifting (including the initial boot mechanism). My advice to you if you want
to write an OS targeting a developer board is to use one of the many open
hardware platforms rather than the Raspberry Pi specifically. The Raspberry
Pi's are better for tinkering with stuff that runs atop of the OS rather than
designing kernels.

~~~
giancarlostoro
Which platforms (hardware) are good for this? I mostly want to mess with Linux
on the Pi, but wouldn't mind trying some assembly on a cheaper board to learn
more about bare metal programming.

------
Ultimatt
Readers understand this isn't close to being an operating system right? You
get the first boot sector of a floppy for free from the BIOS. This isn't even
as complex as the most simple boot loader. It doesn't handle loading more
sectors of the floppy let alone being like an OS.

It's hello world in assembly, loaded onto the first sector of an emulated
floppy. That's neat, but nothing to do with operating systems. Other than
you've now learnt the very first stage of bootstrapping from a floppy disk
back in the 90s. Which is cool, and good info to know and start out with.

I get the vast majority of people seeing this post have probably only ever
experienced nodejs, or Ruby on Rails or something equally high level. But this
is trivial with respect to an operating system or even a boot loader.

------
tbrock
Seems cool, anyone know how this compares to similar projects out there? In
thinking of doing an OS course soon as a refresher.

------
z3t4
I wonder if assembly languages will have a comeback now in the era of
virtualization ... ?

------
fellellor
What kind of hardware would I require to do this project on my own?

------
Jeaye
That's not an operating system; it's a trivial kernel. Linux, in all its
complexity, is still not an operating system; it's a kernel.

For anyone seriously interested in building something less trivial, I
recommend starting here:
[http://wiki.osdev.org/Getting_Started](http://wiki.osdev.org/Getting_Started)

~~~
gumby
I've always thought of the operating system basically being everything in
kernel space and as user space being peripheral.

I think we both have our biases.

~~~
jacquesm
No, we don't have 'our biases' you're just plain wrong.

An operating system is _everything_ needed to run a machine, a kernel is the
foundation on top of which all that user space code runs.

So from a unix perspective everything in /usr/bin /bin /usr/local /etc, /boot
and whatever other directories are there after you install makes up the
operating system. Whatever you install after you get the base system up and
running are applications, the programs we run on top of operating systems.

Now, the line can get a little blurry: is 'X' part of the operating system or
not? Is your window manager, are the various built ins? Probably yes, but not
always.

Is a text editor part of your OS? Probably not, but there is a good case to be
made for the fact that without a text editor of any kind an operating system
is fairly useless. But that doesn't make 'libreoffice' or 'sublime' part of
your OS, those are applications.

For myself, I draw the line where a minimum base install stops, so everything
up to and including window manager for a desktop machine (for a headless
machine or server much less than that).

From a very technical perspective you could have an operating system that
consists of just a kernel and _one_ user space program, in that case the
kernel really would be the entirety of the operating system. But that's a
pretty rare case (though it can be done).

This is all written from a UNIX/Linux perspectie, for OS you might draw the
lines a little different and for MS/Windows different still. But those basic
principles apply.

~~~
epboyd
And what about a microkernel environment where device drivers, filesystems,
etc. are in user space?

~~~
jacquesm
They're _still_ part of the operating system.

What you are trying to get at is that everything in userspace is not part of
the kernel and that is correct. But the kernel does not make a complete
operating system.

This is also the reason why the whole GNU/Linux thing existed, without the
userland that GNU provided the Linux kernel would have been pretty useless.

~~~
kiriakasis
My position is a little in between, an OS is the finished you are delivering.

Linux is an OS, just a terrible one without any GNU.

