2026-12-01 22:20:55 -05:00
# OS/161 Learning
My work on the [ops-class.org ](https://ops-class.org/ ) OS/161 assignments (OS/161 2.0.3).
- Upstream: `https://github.com/ops-class/os161` (remote `upstream` )
- My repo: <https://git.minhtrannhat.com/minhtrannhat/os161> (remote `origin` )
## Progress
| Assignment | Topic | Status |
| --- | --- | --- |
| ASST0 | Introduction, tools, code reading | Done (tag `asst0` ) |
| ASST1 | Locks, condition variables, reader-writer locks, synchronization problems | Not started |
| ASST2 | System calls and processes | Not started |
| ASST3 | Virtual memory | Not started |
2026-12-01 22:13:10 -05:00
## Setup
2026-12-01 22:20:55 -05:00
The toolchain runs natively on Arch Linux. It does not use Docker.
2026-12-01 22:13:10 -05:00
2026-12-01 22:20:55 -05:00
1. Install these AUR packages: `mips-harvard-os161-binutils` , `mips-harvard-os161-gcc48` , `mips-harvard-os161-gdb` , `sys161` and `guile2.0` .
2. If a package does not build, read [os161-build-fixes.md ](./os161-build-fixes.md ). It has the fixes for GCC 14 and Python 3.12+.
2026-12-01 22:13:10 -05:00
2026-12-01 22:20:55 -05:00
## Build
2026-12-01 22:13:10 -05:00
2026-12-01 22:20:55 -05:00
Run the script from the repo root:
2026-12-01 22:13:10 -05:00
2026-12-01 22:20:55 -05:00
./recompile.sh # builds the ASST1 kernel config
./recompile.sh DUMBVM # builds a different kernel config
2026-12-01 22:13:10 -05:00
2026-12-01 22:20:55 -05:00
The script does these steps:
2026-12-01 22:13:10 -05:00
2026-12-01 22:20:55 -05:00
- It builds and installs userland.
- It configures, builds and installs the kernel into `root/` .
- It writes `compile_commands.json` for clangd.
2026-12-01 22:13:10 -05:00
2026-12-01 22:20:55 -05:00
## Run
2026-12-01 22:13:10 -05:00
2026-12-01 22:20:55 -05:00
cd root
sys161 kernel
2026-12-01 22:13:10 -05:00
2026-12-01 22:20:55 -05:00
`root/sys161.conf` gives the machine 16 MB of RAM and 8 CPUs. The ASST1 tests need the large RAM size, because the kernel leaks the memory of thread stacks.
## Source tree
- `kern/` : the kernel. `kern/conf/conf.kern` sets which source files go into the kernel build.
- `kern/thread/synch.c` : the synchronization primitives (ASST1).
- `kern/synchprobs/` : the synchronization problems (ASST1).
- `userland/` : the user programs and test programs.
- `test161/` : the test161 targets and tests.
## Debugging
Follow the steps at <https://people.ece.ubc.ca/~os161/os161-site/gdb-attach.html>.
## Assignment answers
- [Assignment 0 ](./Assignment0.md )
- [Assignment 1 ](./Assignment1.md )