From 1028f6aa096059ce036df17c9df82de81f8b52fe Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Mon, 28 Dec 2015 13:57:52 +0100 Subject: [PATCH 1/5] Small changes to preface --- src/preface.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/preface.md b/src/preface.md index 1d0e495..e8de5b2 100644 --- a/src/preface.md +++ b/src/preface.md @@ -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. @@ -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’. @@ -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. @@ -98,8 +98,8 @@ 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. @@ -107,12 +107,12 @@ 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 From 95c28ba8637d6920fb4067d9f4e6282cc5c36c5e Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Mon, 28 Dec 2015 14:17:16 +0100 Subject: [PATCH 2/5] Small changes to "what" --- src/what.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/what.md b/src/what.md index 8c12d19..ddcbd1b 100644 --- a/src/what.md +++ b/src/what.md @@ -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 and OS. For example, many operating +systems are often marketed as coming equipped with an internet browser or email +client. Are internet 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 @@ -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: @@ -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: @@ -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 allows 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 From 07fd2a502474f3cce217236c0604ad84e0a0133a Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Mon, 28 Dec 2015 14:33:59 +0100 Subject: [PATCH 3/5] Expand discussion of kernel vs. userland --- src/what-kind-is-there.md | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/what-kind-is-there.md b/src/what-kind-is-there.md index 59619bf..4ee6a0c 100644 --- a/src/what-kind-is-there.md +++ b/src/what-kind-is-there.md @@ -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 From 01933d017eacd345db1544ae594ec78dcafd8247 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Mon, 28 Dec 2015 14:46:36 +0100 Subject: [PATCH 4/5] Small changes to tools --- src/tools.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/tools.md b/src/tools.md index 49e399b..34bec5d 100644 --- a/src/tools.md +++ b/src/tools.md @@ -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 @@ -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 @@ -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; @@ -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 $ From 9aef525baf62feaaf1088e1b8deb9d5efaa4f78f Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Mon, 28 Dec 2015 23:43:37 +0100 Subject: [PATCH 5/5] Changes based on @steveklabnik's feedback --- src/preface.md | 2 +- src/what.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/preface.md b/src/preface.md index e8de5b2..540f853 100644 --- a/src/preface.md +++ b/src/preface.md @@ -45,7 +45,7 @@ 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 +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’. diff --git a/src/what.md b/src/what.md index ddcbd1b..ccc5f16 100644 --- a/src/what.md +++ b/src/what.md @@ -5,9 +5,9 @@ are a lot of different kinds of operating systems, and they all do different kinds of things. Some things are commonly bundled with operating systems, but are arguably not -part of the essence of what makes an OS and OS. For example, many operating -systems are often marketed as coming equipped with an internet browser or email -client. Are internet browsers and email clients essential to operating systems? +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. @@ -90,7 +90,7 @@ 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: it allows applies to +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