CS 3400: Operating Systems
==========================

“xv6” refers to the [xv6 commentary book](xv6-riscv-book/book.pdf), our guide to the
xv6 operating system source code.

“3ep” refers to [*Operating Systems: Three Easy Pieces*](http://pages.cs.wisc.edu/~remzi/OSTEP/),
 our (free) primary text.

- - - - -

Resourses
=========

* [Syllabus](syllabus.php)
* [Xv6 main landing page](https://pdos.csail.mit.edu/6.828/2020/xv6.html)
* [Multi-Threaded Programming with POSIX Threads](https://www.cs.kent.edu/~ruttan/sysprog/lectures/multi-thread/multi-thread.html)

Kernels
-------

1. [Hello, world](1-hello-world.tar.gz)
2. [Coroutines](2-coroutines.tar.gz)
3. [Threads](3-threads.tar.gz)
4. [Spinlocks](4-spinlocks.tar.gz)
5. [Interrupts](5-interrupts.tar.gz)


Projects
--------

1. [Tracing the threads kernel with GDB](asst1-trace-threads-kernel.html)



Linux users
-----------

To install the tools you need for this class using Debian:

    sudo apt install git build-essential gcc-riscv64-linux-gnu gdb-multiarch qemu-system-misc

Note: make sure you have an up-to-date Linux distribution. Notably
Ubuntu 22.04 is too old.


MacOS users
-----------

Homebrew is a command line tool for MacOS for installing open source
software. If you do not already have it, install it here:

* https://brew.sh/

Be careful to note the instructions it sometimes gives at the end of the
install process. You may need to complete a manual step and/or log out/log in
before it is completely ready.

Next install the tools:

    xcode-select --install
    brew install riscv64-elf-gcc qemu riscv64-elf-gdb

You must also edit the xv6 Makefile if you will be using the debugger. Find the line:

    QEMU = qemu-system-riscv64

and add this line right after it:

    GDB = $(TOOLPREFIX)gdb

then in the `qemu-gdb` target, find:

    @echo "*** Now run 'gdb' in another window." 1>&2

and replace it with:

    @echo "*** In another terminal, run: $(GDB) -x .gdbinit" 1>&2


Installing xv6
--------------

To start with a fresh instance of xv6:

    git clone https://github.com/mit-pdos/xv6-riscv.git

In the main directory you should be able to run `make qemu` to build and launch
the system. Typing `ctrl-a x` will quit.
