CS 161: Operating Systems

Tuesday/Thursday 1:00-2:30

Pierce 301


Home Syllabus Assignments Resources Piazza

Setting up the Course Appliance

Introduction

For this course, we will be using virtual machines (namely the CS50 appliance) for working on and submitting problem sets. Thanks to CS50, CS51, and CS61 for the content below. If for some reason, you need an environment other than the virtual machines, please contact the course staff.

If you took CS61 this past Fall, then you already have the correct appliance installed, so you can skip directly to Installing the CS161 tools.

Installing a Hypervisor

To run the CS50 appliance, you'll need a hypervisor running on your native OS (VMware Fusion for Mac OS and VMware Workstation for Windows or Linux). If you need to download VMware Fusion or VMware Workstation please fill out this form.

Installing your VM

If you need to install the 2014 version of the CS50 appliance on your machine, follow these instructions.

Once you have your appliance running, open the terminal emulator (click on the screen icon next to the Chrome icon in the bottom tool bar). At the command line type:

    update50
Do not use any other means of updating software that comes with the appliance.

There are two ways you can use your CS50 appliance. You can use your appliance in the window that pops up when you start it up. Alternately, you can access it remotely from your host (real) computer via a network connection. Look at the bottom-right corner of the machine window. You will see an IP address, such as 192.168.166.128. You can ssh (or sftp) to this IP address as ssh jharvard@192.168.166.128. This way, you can treat the appliance as a server and edit files as you would on any remote server, either with an editor that can use sftp, such as TextWrangler or Notepad++, or using ssh and vim, emacs, nano, etc.

Install CS161 Tools

Copy this shell script (cs161.sh) onto your virtual machine (you can use scp or sftp to move files onto your VM, or just download from within the appliance with wget http://www.eecs.harvard.edu/~margo/cs161/resources/cs161.sh) and then execute it with source cs161.sh. (In case you didn't catch it when you updated your VM, the root password on the appliance is crimson.) Now, update your environment to find everything that was just built/installed either by a) closing your terminal window and opening a new one, or b) typing source .bashrc.

The script will take a while (several minutes), but it will install all the tools you will need for the course. You may be wondering just what all those tools are!

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, 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.