
Bootstrap yourself to write an OS from scratch - happy-go-lucky
https://github.com/tuhdo/os01
======
ggambetta
I love this :D Very much in the spirit of my own _Computer Graphics from
scratch_ [0]

On an unrelated topic, I wonder whether this popping up in the front page is
indirectly related to this comment [1] I posted here yesterday. Many, many
times I read interesting comments on HN posts, forget about the topic, and a
day or two later, another closely related post appears on the front page. I
suppose these comments generate follow-up research that ends up in other
interesting articles being discovered and shared. Is it just me? Have you
observed this as well? Is HN actually becoming some sort of hacker collective
consciousness?

[0] [http://www.gabrielgambetta.com/computer-graphics-from-
scratc...](http://www.gabrielgambetta.com/computer-graphics-from-scratch)

[1]
[https://news.ycombinator.com/item?id=16460633](https://news.ycombinator.com/item?id=16460633)

~~~
cabaalis
So one use I have for HN is that I upvote submissions that are things that I
want to come back to and read later. I know bookmarks are kind of made for
this, but I've never really gotten into the bookmark thing. (For that matter,
I also rarely use the speed dial on my phone..) That's probably because I
change computers/browsers regularly, and having lost all my bookmarks years
and years ago, I stopped using them.

It also bothers me to treat upvoting "comments" this way.. I want it to stay
under the "upvoted submissions" link on my profile. So I googled "computer
graphics from scratch site:news.ycombinator.com" and upvoted the first
submission that linked to your page.

I guess what I'm getting at is that method somehow feels wrong to me. Anyone
have suggestions for "read-it-later" type bookmarks?

~~~
stevekemp
>That's probably because I change computers/browsers regularly, and having
lost all my bookmarks years and years ago, I stopped using them.

Something similar happened to me, so I started storing my bookmarks under
revision control. I don't add to them too often, so committing & pushing is a
process that reminds me to not bookmark things unless they're _really_
interesting.

[https://github.com/skx/bookmarks.public](https://github.com/skx/bookmarks.public)

~~~
tebugst
cool. I was looking to build something like this for a while. But never give
serious thoughts. I am inspired again now. Along with links/bookmarks, I
really want a support for words also. Because many times, it is just easy to
save words and later query using google e.g. Radix Sort

------
psyc
At a glance, this looks to be the most gloriously valuable thing I've seen in
eons. Due to the software industry's resounding success at canceling out the
resounding successes of the hardware industry, causing veritable
supercomputers to groan under the weight of such complex tasks as displaying a
character in a timely manner after I type it, I plan to spend my retirement
years reinventing the whole stack from scratch, Terry A. Davis style. It's my
way of seeking justice for all the times I had to go get a coffee while my OS
renamed a folder or the browser struggled to return to usable state after I
foolishly risked _scrolling the page_. I usually conclude that the only sane
way to do this would be to build on top of a bare-bones linux kernel, but
perhaps something in this book will persuade me to set even less realistic
goals. At any rate, looks like a fantastic resource!

~~~
gunn
See here for other people with the same idea (and others):
[https://groups.google.com/forum/#!forum/idealos-
design](https://groups.google.com/forum/#!forum/idealos-design)

------
vectorEQ
bit sad in the era of 64 bit computing still every resource is at most about
protected mode. osdev wiki has some info about long mode, but it's all
fragmented. Been working now for ages to try to decipher amd and intel manuals
about that :'). Still ,nice this page, always good to inspire people to write
their own system softwares because i think it's to much 'magic' still where as
it's doable even for 1 person to write an OS that is dedicated to for example
a single task runnign in user mode. writing a multi-user / multi-purpose OS is
maybe more work, but in those OSs a lot of problems exist today which is
causing a need for people (imho) to step back and look at if this is really
the way we want to go with computing... i don't see why a webserver or
something with a single purpose like that needs to be on a multi-purpose OS.
It just increases complexity and overhead and people have a world of trouble
configuring an OS to do just 1 task good, have to stip our 90% of what comes
with a basic install to reduce attack surface and get resource usage under
control. I hope we will see more dedicated purpose OSes come up which handle
64 bit, and perhaps someday some resources for programming specifically that.
I'm thinking of sharing some of my knowledge on the area sometime, but i dont
know how much interest there is and seeing as i'm a bad writer and still
pretty shit coder it will probarbly take me too much time now compared to how
much use it would be (if i do it, compared to some veteran in the field!).

~~~
eadmund
> bit sad in the era of 64 bit computing still every resource is at most about
> protected mode.

I've an interest in writing a hobbyist OS, and I completely agree. Also,
(almost) everything focuses on BIOS, rather than UEFI. And again, (almost)
everything focuses on calling things from C, with a minimal amount of
assembly, rather than doing everything from assembly.

I'd like to see a resource which walks through an honest-to-goodness minimal
UEFI application written in assembly. At the moment, I think that I'll need to
write it myself …

~~~
pjmlp
On the doing everything from Assembly.

[https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/i...](https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/index.html)

------
stfwn
It’s awesome in the most literal sense of the word that someone wrote a
300-page _book_ on this topic and just put it online for anyone to read for
free. I hope I can contribute at this level at some point.

------
earenndil
Another good link for people looking for something like this:
[https://wiki.osdev.org/Main_Page](https://wiki.osdev.org/Main_Page)

~~~
BenjiWiebe
Also BrokenThorn entertainment has an EXCELLENT tutorial on writing an OS from
scratch.

------
crusso
I started following a couple of OS-from-scratch guides a while back. There are
a few that are very similar and will get you through the basics. I got things
working up to the point of having a little OS that would boot up and take
keyboard input and display it in a text terminal in various colors. This was
all very straightforward and worked pretty well.

The next thing I wanted to work on was some type of process manager that would
allow for multiple processes to run, each in a protected memory space. That's
when it started to get pretty hairy and that little learning project bogged
down. As I recall, my decision paralysis mostly stemmed from the fact that
there were successive generations of ways to handle memory allocation and
protection on the i386/x86_64 families, and the clear way that I should
implement my little OS branched off into a lot of choices with ramifications
that I was hesitating to commit to.

I'd love to go back and pick that project up where I left off. I'll muscle
past that learning curve, but are there any good guides out there with more
information on how modern 64-bit process management (including memory
protection) is accomplished?

------
kbuzby
Seems analogous to the XV6 project:
[https://pdos.csail.mit.edu/6.828/2017/xv6.html](https://pdos.csail.mit.edu/6.828/2017/xv6.html)

~~~
WalterGR
_For many years, MIT had no operating systems course. In the fall of 2002, one
was created to teach operating systems engineering._

That's surprising, since just about every CS program offers/requires an OS
course. Does anyone know what took MIT so long?

------
bernardino
Anyone know of any other resources about operating systems for beginners?

~~~
indigochill
For an introduction to the theory, Nand2Tetris[0] starts you out with nothing
more than an xor gate from which you construct every other logic gate,
implement a CPU, then in part 2 you build an OS on top of that. Although that
sounds intimidating, it's actually incredibly accessible. I went in knowing
nothing about the topic, and was able to implement the CPU by the end of the
course, which was a major confidence boost. Also I found the lessons learned
from the course (basically, layer simple systems with clear interfaces
together to get complex systems) extended well beyond just CPUs and OSes to
software design in general.

That uses a very simple educational architecture designed for ease of
learning, though. If you prefer a good introductory resource for real-world
operating systems, I just finished Georgia Tech's Intro to OS graduate
course[1] and found it very accessible as well, and now feel reasonably
comfortable with the theory when reading about OS topics elsewhere.

[0] [http://www.nand2tetris.org/](http://www.nand2tetris.org/)

[1] [https://www.udacity.com/course/introduction-to-operating-
sys...](https://www.udacity.com/course/introduction-to-operating-systems--
ud923)

~~~
twtw
I haven't done the course, but I'm fairly sure that XOR isn't a universal
gate, so you probably don't start out with "nothing more than an xor gate."
Based on the name, I would guess you start out with only NAND, which is a
universal gate.

~~~
indigochill
Sorry, obviously yes, it starts with NAND. No idea where I got XOR from.

------
Hydraulix989
I would've done paging before task switching because TSS is such a broken way
of doing things. Processes should live in their own separate address spaces.

------
BlackjackCF
Been following this project since it was in the rougher earlier days. Really
glad to see it come together. Congrats!

------
verroq
How many of these large grand “tutorials” actually get completed?

I am still waiting to write my compiler in haskell [0] and to learn linux
inside out [1]

[0] [http://dev.stephendiehl.com/fun/](http://dev.stephendiehl.com/fun/)

[1] [https://github.com/0xAX/linux-insides](https://github.com/0xAX/linux-
insides)

------
thedirt0115
Wow, there is a lot of really good info in here, keep up the good work!
Looking forward to part 3!

------
joeblau
Is there a book like this but on building your own custom version of Android?

~~~
spc476
Yes. _Bootstrap yourself to write an OS from scratch_. As it says at the very
top: "How to write an operating system from scratch by reading hardware
datasheets. In the real world, it works like that. You won't be able to
consult Google for a quick answer." To write an Android clone, you'll need to
understand how cellphones work, which involves reading hardware datasheets
(and possibly signing a few dozen or so NDAs to obtain the information).

