Ancient CS 61 Content Warning!!!!!1!!!
This is not the current version of the class.
This site was automatically translated from a wiki. The translation may have introduced mistakes (and the content might have been wrong to begin with).

Infrastructure

For this course, we will be using a virtual machine, namely Ubuntu, for working on and submitting problem sets. All problem sets can be run on other Linux machines or VMs, most problem sets can also be done on Mac OS X machines. However, we recommend you at least check your work on Ubuntu or another Linux VM, in case you are accidentally relying on Mac-specific behavior.

Download an Ubuntu VM

You will need an Ubuntu VM for some assignments. Most problem sets can also be run on other Linux machines or Mac OS X machines. However, we recommend you at least check your work on a Linux VM, in case you are accidentally relying on Mac-specific behavior. We recommend the latest LTS release, Ubuntu 16.04.3 LTS (Xenial Xerus). You can download it from Ubuntu here. Note that Ubuntu is free and you don't need to make a donation.

Install a virtual machine monitor (VMM)

To run the VM, you will need to install a virtual machine monitor. We recommend using VMWare.

Mac OSX (VMWare Fusion 8)

You are now ready to create a new Ubuntu VM in VMWare Fusion.

Windows (VMWare Workstation 12)

You are now ready to create a new Ubuntu VM in VMWare Workstation.

Linux (VMware Workstation 12)

You are now ready to create a new Ubuntu VM in VMWare Workstation.

Updating your compiler

The CS61 VM, unfortunately, has a relatively old compiler (GCC-4.8). Here’s how to upgrade the CS61 VM to use Clang 3.8, a more modern compiler.

sudo apt-get update
sudo apt-get install clang
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 50

Or you can choose GCC-6.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install clang
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-6 50

On Mac OS X, install a newer compiler with Homebrew. I've installed the gcc-6 package. Then you can specify a specific compiler like so:

make SANITIZE=1 CC=gcc-6

Install tools

Run the following command to download install miscellaneous tools we will be using throughout the course:

 sudo apt-get update
 sudo apt-get install git kcachegrind linux-tools-generic bochs qemu

When prompted, type y and hit Enter to approve the tool installations, and then you're ready to hack!

Version control with Git

We will be using git with GitHub Classroom for turning in problem set submissions and version control.

What is git?

Git was developed by Linus Torvalds for development of the Linux kernel. It’s is a distributed version control system, which means it supports many local repositories which each track changes and can synchronize with each other in a peer-to-peer fashion. It’s the best widely-available version control system, and certainly the most widely used. For information on how to use git, see:

Cloning the problem set repository

Problem sets will be released using the cs61/cs61-psets-f17 repository.

Please click this link to create your own private clone of the problem sets repository. You’ll clone that repository onto your computer, do work there, and then push your work upstream to the GitHub-hosted repository for us to grade.

Here’s how it should work.

  1. Click the link.
  2. Log in to GitHub, or create an account.
  3. The link should automagically clone the repository. For instance, if your account name was kohler-dumb, you should get a repository called cs61/cs61-f17-psets-kohler-dumb.

Working with a partner? No problem. Find out their GitHub username, and then add them to your repository as a collaborator using Settings > Collaborators & teams.

Teaching GitHub about your identity

The easiest way to access GitHub repositories is using an SSH key, a secret key stored on your CS61 VM that defines your identity. This handy HCS tutorial may be useful to teach you about SSH; or just follow the steps below to create a key for your virtual machine.

  1. Launch your VM and open a terminal.
  2. Run ssh-keygen -t rsa -b 2048 and follow the instructions.
    • Press enter to use the default file path and key name (should be ~/.ssh/id_rsa).
    • Choose a password or leave it empty.

This creates your ssh keys, which live in the directory ~/.ssh. Your public key is in the file ~/.ssh/id_rsa.pub.

Finally, tell GitHub about this key.

  1. Run cat .ssh/id_rsa.pub to display your public key.
  2. Copy your public key (that is, select the text on the screen, and copy it to the clipboard).
  3. In GitHub, go to your profile settings page (accessible via the upper-rightmost link—this looks like a bunch of pixels for new accounts). Select “SSH and GPG keys” and hit the “New SSH key” button. Then copy and paste the contents of your ~/.ssh/id_rsa.pub file into the “Key” section. Give the key a sensible title, hit the “Add SSH key” button, and you’re good to go.

Creating a local clone

Once GitHub knows your SSH identity, you’re ready to clone your problem set repository and start doing work! Here’s how to get a local copy of the repo on your machine:

     git config --global user.name "FIRST_NAME LAST_NAME"
     git config --global user.email "YOUR_@COLLEGE_EMAIL"
     git clone REPO_URL

where REPO_URL is the URL for your repository. This will be something like git@github.com:cs61/cs61-f17-psets-yourname.git, and can be obtained on GitHub by clicking the “Clown or download” button. You want to clone using SSH, not HTTPS, so you might need to click “Use SSH”.

Troubleshooting

If you are having any trouble with your keys (e.g., you cannot clone a repo because "the connection timed out"), check if your firewall is blocking port 22, and open port 22 if it is blocked. You can use your favorite search engine to figure out how to do this.

Obtaining future problem sets

The following should be done every time a new pset is released or an old pset is updated.

This will download the latest pset directory into your repo.

Another way that’s convenient long-term is to add a handout remote to your repository. That works like this:

 git remote add handout git://github.com/cs61/cs61-psets-f17.git

Now you can:

Submitting problem sets

Be sure that git status (from your “cs61-f17-psets-yourname” directory) reports that you have no uncommitted changes.

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

If git status reports that you have uncommitted changes, you'll need to commit these changes! Read through our Git tutorial for details.

Then, run git push, and be sure Git reports that everything is up-to-date:

$ git push
Everything up-to-date

Head over to the grading server and make sure that your code passes all tests you expect it to. The first time you visit the grading server, enter your official email address for the username (that will be your college.harvard.edu address if you are a college student and the email address you used when you registered for the class if you are an extension student. Then request a password reset. Once you've got your password, you can log into the grading server and enter the URL of your repository.

Obtaining lecture code

The code we’ll look at in lecture, and the lecture exercises, is available at the beginning of lecture in a public Git repository. Here’s how to obtain it the first time:

     git clone git://github.com/cs61/cs61-lectures.git

This will put the lecture code in a directory called cs61-lectures.

To update exercise code for a new lecture, change into that directory and run git pull