Winter 2023
Stanford University
This course focuses on providing an introduction to operating systems with a specific emphasis on embedded systems, interacting with hardware, and verification. Students will have hands-on experience through labs and will build their own simple, clean operating system for an ARM-based Raspberry Pi. The course offers opportunities to work with real hardware and primary-source documents, encouraging a deeper understanding of computation on real hardware.
Tl;dr:
CS140E is an introductory operating systems course. It roughly covers the same high-level material as CS 212 (formerly CS 140), but with a focus on embedded systems, interacting directly with hardware, and verification. Both courses cover concepts such as virtual memory, filesystems, networking, and scheduling, but take different approaches to doing so. By the end of 140E, you will have (hopefully) built your own simple, clean operating system for the widely-used, ARM-based Raspberry Pi.
Note that nothing here is strictly required, as long as you're willing to learn it on-the-fly. However, the course material is designed assuming most students will have the following:
No previous experience with operating systems, raspberry pis, or embedded programming is required.
If you want to take the course but are worried about any of these, talk to us! We can point you to resources to help catch up, should you need them.
140e is a lab-based class with no explicit lectures. We will do two three-to-five hour labs each week. You should be able to complete almost all of the lab in one sitting. There will be several homeworks, that act as mini-capstone projects tying together the preceding labs. Since we are breaking new ground by having the class virtual only, we may add an additional discussion section to help people that need it.
By the end of the class you will have built your own simple, clean OS for the widely-used, ARM-based raspberry pi --- including interrupts, threads, virtual memory, and a simple file system. Your OS should serve as a good base for interesting, real, sensor-based / embedded projects.
We try to work directly with primary-sources (the Broadcom and ARM6 manuals, various datasheets) since learning to understand such prose is one of the super-powers of good systems hackers. It will also give you the tools to go off on your own after the course and fearlessly build sensor-based devices using only their datasheets.
This course differs from most OS courses in that it uses real hardware instead of a fake simulator, and almost all of the code will be written by you.
After this quarter, you'll know/enact many cool things your peers do not. You will also have a too-rare concrete understanding of how computation works on real hardware. This understanding will serve you in many other contexts. For what it is worth, everything you build will be stuff we found personally useful. There will be zero (intentional) busy-work.
The goal of the class is to help students who are very motivated and/or very good to go far, quickly. We focus on building small, simple but real OS subsystems --- threading, virtual memory, etc --- that can be used to build many other things.
You should take this class if:
You write code well OR (you don't yet write code well AND have a lot of time to devote to the class);
AND you find these systems topics interesting.
The people that found the class valuable in the past were entirely drawn from this demographic. I would say that if you struggle building stuff and are not already interested in the topic, then it's probably better to take a different class. I would particularly advise against taking this class if you were looking for an easier way to satisfy a cs140 requirement.
It always helps, but you do not need any background in hardware or OS stuff to do well in the class. In fact, you don't even need to have been trained in CS: one of the best students from last year was a physics PhD student with fairly minimal background in coding, so we've had fantastic luck with non-CS folks :) With that said, the less background you have, the more motivation you might need.
By the end of the class you'll have learned how to comfortably do many things that may well seem like superpowers and could easily serve you well for the next few decades.
If you have background in the "embedded" space, it's worth taking b/c you'll learn a bunch of useful but not widely-known tricks (I'll pay for your supplies and a pitcher of beer if this claim turns out to be false!)
It's also super fun. The code you'll write can be used to as a basis for building many interesting systems.
As one measure: Last year, I taught two extra follow-on classes (cs240lx and cs340lx) ``for free'' because of all the interesting things that came up from cs140e. In addition, it's caused me to write more code than I have since grad school. At my age, that's an unusual result :)
A quick skim might falsely pattern-match on a couple of things:
cs140e is NOT an easier version of cs140. In fact, it can be quite a bit harder, since we work with raw hardware, and primarily use raw datasheets and ARMv6 architecture manuals rather than pre-digested text books or simulators.
I'd say about 1/3 of the teaching evals from last year explicitly stated "do not take cs140e as an easier cs140".
On the plus side, this approach is the adult way to do things, so you will be better prepared after the class for operating autonomously in the real world without safety nets or help. Everything you'll build will be stuff we personally found useful. There is no (intentional) busywork.
Similarly, while we do use a raspberry pi for this class, and there are tons of blog posts/instructables/classes for novices showing how to use the r/pi to do simple things, this class is not that.
You'll be writing virtual memory systems, SD card file systems, threads, i2c device drivers on raw hardware rather than cut-and-pasting some python on a library to blinky a light.
We use the r/pi because its fairly cheap, holds up to electrical mistakes pretty well, runs a legit processor with legit hardware and is small enough to carry around easily.
With that said, I set aside the entire quarter to work on this course, so am happy to help people that need it --- some of the biggest success stories last year were from students that had an initially large gap between their understanding and the topic but started to really "get it" after some weeks of struggle.
CS 140E is unlike many other Stanford CS classes in one major way: it isn't simplified for a classroom setting. The hardware you're interacting with is the same hardware the Linux kernel interacts with. When there's a bug in the hardware, we have to work around it. When the documents are wrong, we have to find the errors.
This is a tricky question, since there's no one particular set of factors which is correlated with success in this class. There's a subset of people who love it, and a subset who don't.
In general, the people who enjoy CS 140E tend to fit the following:
However, since the class is fairly unusual in a lot of ways, it also tends to appeal to people from atypical backgrounds. Some of our most successful students in the past have been from non-CS majors. As mentioned below, we don't have any hard prerequisites; this is specifically because we want the course to be accessible to anyone who's interested in learning the material, regardless of background.
CS 140E can count as a substitute for CS 212 (including for PhD students who need to fulfill an OS breadth requirement). It is approximately 80% of the coding work of CS 212, but will probably require a more strenuous type of thinking at some points. The main differences are:
With that said, you are strongly encouraged to sit in on the CS 212 lectures if you can; Mazières is incredibly knowledgable, and will serve as a great counterpoint to what we do.
The flip side of working with raw hardware and documentation is that this class is much less structured than other CS classes you might have taken before. If you're the kind of person who loves figuring things out and exploring, great! If you prefer more structured assignments and lectures, you might want to consider CS 212 instead.