# CS162: Operating System

## Descriptions

- Offered by: UC Berkeley
- Prerequisites: CS61A, CS61B, CS61C; Solid C programming and GDB debugging skills
- Programming Languages: C, x86 Assembly
- Difficulty: 🌟🌟🌟🌟🌟🌟
- Class Hour: 200 hours+

The course impressed me in two aspects:

Firstly, the textbook: Operating Systems: Principles and Practice (2nd Edition) consists of four volumes. It is written in a very accessible yet profound way, with vivid and sometimes even humorous language. It serves as an excellent supplement to the lecture videos and perfectly fills some theoretical gaps left by MIT 6.S081. This is also the experimental textbook for CMU's OS course (15410), I highly recommend reading it! Related resources are shared in the "Classic Books" section of this repository.

Secondly, the project for this course *Pintos* is a great journey for system hackers. *Pintos* is a toy operating system developed at Stanford for educational use. The author Ben Pfaff even published a [paper](https://benpfaff.org/papers/pintos.pdf) to explain the design principles of *Pintos*.

Unlike the small but comprehensive design philosophy in MIT's xv6 labs, *Pintos* emphasizes system design and implementation more. The codebase is about 10,000 LOC and only provides the basic functions of a working operating system. Each project has almost no boilerplate code; you must design the implementation yourself and weigh the pros and cons of different schemes. The four projects let you add scheduler (Project1), system calls (Project2), virtual memory (Project3), and the file system (Project4) *(Note: The specific requirements for CS162 Pintos differ slightly; see the assignment description below)* to this extremely simple operating system. All projects leave a a big design space for students and require more than 2000 LOC. Based on the [feedback](https://www.quora.com/What-is-it-like-to-take-CS-140-Operating-Systems-at-Stanford) from Stanford students, the latter two projects take over 40 hours per person even in teams of 3-4 people.

Although it is tough, Stanford, Berkeley, JHU and many other top U.S. colleges have chosen *Pintos* as their OS course project. If you're really interested in operating systems, it will greatly improve your ability to write and debug low-level system code and teach you how to design a system by making trade-offs between different possibilities. For me, it is an invaluable experience to design, implement, and debug a large system independently.

*Pintos* will also be introduced as a course project in Peking University's OS Course. In the Spring 2022 semester, I worked with [another TA](https://github.com/AlfredThiel) to write a comprehensive [lab documentation](https://pkuflyingpig.gitbook.io/pintos) and provided a docker image for the ease of cross-platform development. In the last semester before graduation, I hope such an attempt can make more people fall in love with systems and contribute to the field of systems in China.

## Course Resources

- Course Website: 
  - [Current Semester](https://cs162.org/)
  - [Fa25 - Wayback Machine](https://web.archive.org/web/20251211080516/https://cs162.org/)
- Lecture Videos: Currently, three semesters are publicly available: Fall 2020, Fall 2021, and Spring 2022. Based on my experience with the Fall 2025 semester, the **Spring 2022** version is best for self-study. It was recorded in-person (except for the first four lectures), featuring more student-teacher interaction and many valuable questions addressed in class:
  - [Spring 2022 Lecture Videos (Bilibili)](https://www.bilibili.com/video/BV1L541117gr?vd_source=e293470ea109e008c4d9516e39ef318f&p=5&spm_id_from=333.788.videopod.episodes)
  - [Fall 2020 Lecture Videos (Bilibili)](https://www.bilibili.com/video/BV1MwDSYWEKy?spm_id_from=333.788.videopod.sections&vd_source=e293470ea109e008c4d9516e39ef318f&p=24)
  - Fall 2021 video links can be found on the [Fall 2021 Website](https://web.archive.org/web/20211216005317/https://cs162.org/).
- Textbook: [Operating Systems: Principles and Practice (2nd Edition)](http://ospp.cs.washington.edu/). This textbook is an excellent supplement to the lectures and is highly recommended.
- Assignments: Consists of 3 Projects and 6 Homeworks. (The workload for each Homework is roughly equivalent to a full Project in most other open-source courses. Projects were originally designed for teams; self-studying them alone involves a significant workload):
  - 3 Projects (each with complete local tests):
    1. User Programs: Implement argument parsing for process execution, process-related system calls (including the `fork` syscall added in 2025), and file-related system calls.
    2. Threads: Implement a non-busy-waiting `timer_sleep` function, a strict priority scheduler, multi-threading support, and a simplified `pthread` library. (Note: This differs from the Multi-Level Feedback Queue requirements in the PKU Pintos and Stanford CS212 versions).
    3. File Systems: Implement a kernel Buffer Cache, extensible files, and subdirectories.
  - 6 Homeworks: Includes a sub-task for the MapReduce assignment. Both HTTP and MapReduce assignments have two versions: C and Rust. Except for the Memory lab, most Homeworks lack local autograders (though most can be manually tested effectively, except for MapReduce, which can be replaced by the [MIT 6.824 MapReduce lab](https://pdos.csail.mit.edu/6.824/labs/lab-mr.html)).
    1. List: Familiarize with the built-in linked list structure in Pintos.
    2. Shell: Implement a Shell supporting directory commands, program execution, path parsing, redirection, pipes, and signal handling.
    3. HTTP: Implement an HTTP server supporting GET requests.
    4. Memory: Implement memory management functions like `sbrk` and `malloc`.
    5. MapReduce: Implement a fault-tolerant MapReduce system (including the RPC Lab).

---

## Personal Resources

All resources and assignment implementations (including code, design documents, and starter code) used during my study of the **Fall 2025** semester are summarized in the [@RisingUppercut/CS162-fall25 - GitHub](https://github.com/RisingUppercut/UCB_CS162_2025Fall) repository.

Since the Operating System Course at PKU uses the project, my implementation is not open source to prevent plagiarism.
