Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #13 from rylev/change-suggestions
Browse files Browse the repository at this point in the history
Small Changes To Beginning of the Book
  • Loading branch information
steveklabnik committed Dec 29, 2015
2 parents f6b2bbd + 9aef525 commit 078284a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 38 deletions.
16 changes: 8 additions & 8 deletions src/preface.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ learning Rust, but you might accidentally along the way.

You can find all of this stuff [on GitHub](https://github.com/intermezzOS/).
This book is in the `book` repository, the kernel is in `kernel`, and the
website is there, too. Feel free to open issues on the [RFCs
website is there too. Feel free to open issues on the [RFCs
repo](https://github.com/intermezzOS/rfcs) if you want to discuss things
in a general sense, and send bug reports and PRs to the appropriate repos
if you’d like to help with a particular component.
Expand All @@ -44,8 +44,8 @@ are a lot of people who do hobby operating system work, but... I don’t like
their attitudes.

You see, a lot of people see low-level programming as some kind of superior,
only-for-the-smartest kind of thing. They have a puritanical world-view: I
suffered to learn this, so you too must suffer, to build character. I think
only-for-the-smartest kind of thing. They have a puritanical world-view: I
suffered to learn this, so you too must suffer to build character. I think
that’s short sighted. Low level programming _is_ difficult to get into, but
that says more about the teachers’ faults than the students’.

Expand Down Expand Up @@ -73,7 +73,7 @@ myself. A lot of the initial code here is going to be similar to Phil’s.
But I’m going to write about it anyway. There’s a good reason for that:

> Writing is nature’s way of showing us how sloppy our thinking is.
>
>
> - Leslie Lamport
By re-explaining things in my own words, I hope to understand it even better.
Expand All @@ -98,21 +98,21 @@ going to be in my spare time, and I’m learning a lot of this as I go, too.
> to be left behind; every point is a relay and exists only as a relay. A path
> is always between two points, but the in-between has taken on all the
> consistency and enjoys both an autonomy and a direction of its own. The life
> of the nomad is the intermezzo.
>
> of the nomad is the intermezzo.
>
> Deleuze and Guattari, “A Thousand Plateaus”, p380
If you’re not into particular kinds of philosophy, this quote won’t mean a lot.
Let’s look at the dictionary definition:

> An intermezzo, in the most general sense, is a composition which fits between
> other musical or dramatic entities, such as acts of a play or movements of a
> larger musical work.
> larger musical work.
>
> [https://en.wikipedia.org/wiki/Intermezzo](https://en.wikipedia.org/wiki/Intermezzo)
I want this project to be about learning. Learning is often referred to as a
journey. You start off in ignorance, and end in knowledge. In other words,
journey. You start off in ignorance and end in knowledge. In other words,
‘learning’ is that part in the middle, the in-between state.

The tricky thing about learning is, you never stop learning. Once you learn
Expand Down
21 changes: 14 additions & 7 deletions src/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ _every_ kernel must use: assembly language.

## Assembly

Assembly language gives us direct access to a specific machine. If the basis of
computer science is abstraction, the very bottom of the software abstraction layer
is assembly. Below it lies only hardware and physics.

Assembly language looks like this:

```x86asm
; lol.asm
; foo.asm
section .data
global _start
Expand All @@ -28,11 +32,14 @@ loop:
int 80h
```

This is a little program in assembly language. We can run it like this:
This is a little program in assembly language. If it looks totally alien to you,
don't worry. We'll be taking assembly language step by step.

We can run it like this:

```bash
$ nasm -f elf64 lol.asm # assemble into lol.o
$ ld lol.o # link into a.out
$ nasm -f elf64 foo.asm # assemble into foo.o
$ ld foo.o # link into a.out
$ ./a.out # run it
$ echo $? # print out the exit code
10
Expand All @@ -54,7 +61,7 @@ rough edges, but they’re not too big of a deal.
Rust will allow us to write:

```rust
// lol.rs
// foo.rs

use std::process;

Expand All @@ -72,8 +79,8 @@ fn main() {
This does the same thing as our assembly code:

```bash
$ rustc lol.rs # compile our Rust code to lol
$ ./lol # run it
$ rustc foo.rs # compile our Rust code to foo
$ ./foo # run it
$ echo $? # print out the exit code
10
$
Expand Down
30 changes: 17 additions & 13 deletions src/what-kind-is-there.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# What kinds of OS are there?

Okay, so here’s the thing: operating systems are made up of a _lot_ of
components. The core component is called a ‘kernel’. So, as OS developers, when
we categorize operating systems, we tend to categorize them by what kinds of
kernel they have. At the start, our ‘operating system’ will be just the kernel,
and so we’ll tend to focus on kernels for the first part of our journey.

The non-kernel bits of an operating system are called a ‘userland’. It’s where
the users live. This is also why you’ll hear some people say, “It’s
GNU/Linux, not Linux.” That’s because virtually all Linux distributions today
use a Linux kernel + a GNU userland. So the GNU folks are a bit annoyed that
the kernel gets all the credit. By the same token, a lot of people say ‘the
kernel’ when they mean ‘the Linux kernel.’ This gets an entirely different set
of people mad.
Okay, so here’s the thing: operating systems are made up of a _lot_ of components.
The core component is called a ‘kernel’. The non-kernel bits of an operating system
are collevtively called a ‘userland’. Typically a kernel has more direct access to the
machine than a userland and thus acts somewhat like a super user (with powers that even
‘sudo’ cannot give you). A kernel forms the basis of the abstractions and isolations.
So, as OS developers, when we categorize operating systems, we tend to categorize them
by what kinds of kernel they have.

Although you may be used to hearing the term ‘Linux’ used as a name for an
operating system, you may hear some people say, “It’s GNU/Linux, not Linux.”
That’s because virtually all Linux distributions today use a Linux kernel + a
GNU userland. So the GNU folks are a bit annoyed that the kernel gets all
the credit. By the same token, a lot of people say ‘the kernel’ when they mean
‘the Linux kernel.’ This gets an entirely different set of people mad.

Sometimes, it just seems like everything makes everyone mad.

Anyway...

At the start, our ‘operating system’ will be just the kernel, and so we’ll tend
to focus on kernels for the first part of our journey.

The way that we categorize different kernels largely comes down to “what is in
the kernel and what is in userspace.” Upon reading this, you might then think
the easiest kind of kernel to write is the smallest, where everything is in
Expand Down
26 changes: 16 additions & 10 deletions src/what.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ It’s actually kind of difficult to define what an operating system is. There
are a lot of different kinds of operating systems, and they all do different
kinds of things.

There are some shared goals, however. Let’s try this out as a working
definition:
Some things are commonly bundled with operating systems, but are arguably not
part of the essence of what makes an OS an OS. For example, many operating
systems are often marketed as coming equipped with an web browser or email
client. Are web browsers and email clients essential to operating systems?
Many would argue the answer is no.

There are some shared goals we can find among all operating systems, however.
Let’s try this out as a working definition:

> An operating system is a program that provides a platform for other
> programs. It provides two things to these programs: abstractions and
Expand All @@ -28,11 +34,11 @@ Consider a program, running on some hardware:
This program will need to know _exactly_ about what kind of hardware exists.
If you want to run it on a different computer, it will have to know exactly
about that computer too. And if you want to write a second program, you’ll
have to re-write all of that code.
have to re-write a bunch of code for interacting with the hardware.

> All problems in computer science can be solved by another level of
> indirection.
>
>
> - David Wheeler
To solve this problem, we can introduce an abstraction:
Expand Down Expand Up @@ -62,7 +68,7 @@ to each operating system, which is then ported to all the hardware. Whew!
This, of course, leads to the collary to the previous maxim:

> ...except for the problem of too many layers of indirection.
>
>
> - Kevlin Henney
We now have a pattern:
Expand All @@ -84,11 +90,11 @@ to be able to run multiple programs, which is a common feature of many
operating systems, we’ll also need to make sure that multiple programs cannot
access hardware at the same time.

This really applies to more than just hardware though: once we have two
programs, it would not be ideal to let them mess with each other. Consider any
sort of program that deals with your password: if programs could mess with each
other’s memory and code, then a program could trivially steal your password
from another program!
This really applies to more than just hardware though: it also applies to
shared resources (e.g. memory). Once we have two programs, it would
be ideal to not let them mess with each other. Consider any sort of program that
deals with your password: if programs could mess with each other’s memory
and code, then a program could trivially steal your password from another program!

This is just one symptom of a general problem. It’s much better to isolate
programs from each other, for a number of different reasons. For now, we’ll
Expand Down

0 comments on commit 078284a

Please sign in to comment.