CS 161: Operating Systems (Spring 2017)

Tuesday/Thursday 1:00-2:30

Pierce 301


Home Syllabus Assignments Resources Piazza

Setting up the CS 161 VM

For this course, you will use virtual machines to work on and submit problem sets. Before you can download the os161 source code, compile it, and run it, you'll need to create a VM. You'll employ this VM to store, edit, and test the code that you write in this class.

Getting a Base VM Image

As a base VM, CS 161 uses a 64-bit Ubuntu 14.04.5 image. Download that image from this location. Then, use the VirtualBox hypervisor to create a virtual machine which uses the image that you just downloaded---be sure to give the VM a hard drive of at least 8 GB in size. After you create the VM, launch it! You'll have to configure the new VM, e.g., to pick a user name and password. Then you'll have to wait as Ubuntu installs various features.

Installing the CS 161 Tools

In addition to the tools that come pre-installed on the VM, you'll need some CS161-specific tools. We have packaged these tools up in a Personal Package Archive (PPA), which you can easily install. In a terminal window, at the command-line prompt, type this . . .

        % sudo apt-get install -y git
. . . to install the git tools that you'll use to manage your source code. Then, type this:
	% sudo add-apt-repository ppa:cs161/sp2017
	% sudo apt-get update
	% sudo apt-get install os161-toolchain

You may be wondering what the last three commands installed. We're glad you asked!

It should come as no surprise to you that we expect that you will need to use a debugger to complete assignments in this course. The good news is that just about everything you've learned about using gdb will apply to debugging OS/161. However, you may be wondering exactly how this is going to work since you will be building an operating system for something resembling a MIPS processor and you will be running on an Intel-based system.

We use a specially compiled version of gcc (and its associated tools) designed to produce code runnable on System/161. Thus, we have our own version of gcc (available as os161-gcc) and, among other things, our own version of gdb (available as os161-gdb).

For the most part, debugging your kernel will be no different from debugging any other program with gdb. There is a small caveat, however. Consider the following: the program that is actually running on your virtual machine will be System/161 (the executable will be called sys161). You don't want to debug System/161. You want to debug what is being run on System/161. Thus, a little cleverness is required.

You will have gdb communicate with System/161 through a Unix socket in order to send and receive debugging information. Thus, debugging your kernel generally takes three steps (after you've built your kernel (which we will do in class on Thursday), give this a try):

  1. In your installation root directory (~/cs161/root/), launch System/161 but have it wait for a debugger connection:
    % sys161 -w kernel
    
  2. In a different terminal window, again in your installation root directory, launch os161-gdb, giving it the binary that you want to debug:
    % os161-gdb kernel
    
  3. Once in gdb, instruct gdb to connect to System/161:
    (gdb) target remote unix:.sockets/gdb
    

The handout Debugging with GDB provides a brief introduction to gdb and detailed instructions on how to debug your operating system with it.