Systems Programming and Machine Organization
For this course, we will be using a virtual machine, namely the CS50 appliance, for working on and submitting problem sets. All problem sets can be run on other Linux machines or VMs, such as Ubuntu. Most problem sets can also be done on Mac OS X machines. However, we recommend you at least check your work on a Linux VM or the CS50 appliance, in case you are accidentally relying on Mac-specific behavior.
Install a virtual machine monitor and the Appliance
If you have a Mac and are a current Harvard student (including extension), and you do not currently have VMware Fusion installed on your computer, please email the staff. Wait for a reply, and then follow the instructions below to obtain a VMap account and install VMware Fusion. Alternatively, you may install VirtualBox instead of VMware Fusion. However, VMware Fusion has significantly fewer issues with the appliance than VirtualBox, so we recommend filling out the form for VMware Fusion.
Follow the instructions here to install the CS50 appliance on your machine.
Update your appliance
- Open the terminal emulator (the shortcut is in the lower left corner, next to the Google Chrome icon).
- Type the following command and hit Enter. This may take a few minutes to complete.
sudo yum -y update appliance50
- You may be prompted to approve the installation. If so, type y and hit Enter. If not, skip this step.
- Wait for installation complete, and that's it!
Run the following command to download install miscellaneous tools we will be using throughout the course:
sudo yum install gcc-c++ kcachegrind perf strace bochs qemu
When prompted, type y and hit Enter to approve the tool installations, and then you're ready to hack!
Version control with code.seas.harvard.edu
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 by far the best version control system available to us and is increasingly widely used. For information on how to use git, see:
- Our git notes, which include an explanation of version control in general
- SEAS’s git introduction
- The git cheatsheet, a beautiful and fun quick reference guide
- Resources for more links
What is code.seas?
Code.seas is an online git repository and project management website for SEAS. It’s a deployment of gitorious, and acts somewhat like GitHub. We’ll be using code.seas for distributing code and problem sets, and for collecting your work.
Signing up for code.seas
The following only needs to be done once. You may skip steps 1-3 if you already have a working code.seas account.
- Go to https://code.seas.harvard.edu/login.
- Enter your FAS credentials. Extension school students, you can fill out a form to get a FAS account if you don’t already have one.
- You may be directed to an OpenID Verification page that asks you to confirm your identity. Click the "Allow Always" button on the right of the screen. You may then be asked to enter some details for your profile, but will eventually see your Dashboard.
The next step is to create and add SSH keys for your repositories. These keys authenticate you to code.seas, so that no one else can fake your identity. If you have a safe SSH key, use it. Otherwise, check out this handy HCS tutorial, or follow these steps:
- Launch your VM and open a terminal.
ssh-keygen -t dsaand follow the instructions.
- Press enter to use the default file path and key name (should be ~/.ssh/id_dsa).
- 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
Finally, tell code.seas about this key.
- Now run
cat .ssh/id_dsa.pubto display your public key.
- Copy your public key (that is, select the text on the screen, and copy it to the clipboard).
- In the SEAS Code Repository, click “Manage SSH keys”, click "Add SSH Key", paste your key into the field, and click "Save".
You are now ready to use git!
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.
If you are having any trouble logging in, please follow these steps:
- Quit your browser (flush cookies).
- Try to login to code.seas with your FAS account.
- If that fails, you may need to change your FAS password and repeat steps 1 and 2.
- If that fails, email Academic Computing at email@example.com and let them know your FAS account name. They will set up for you a local account.
Obtaining lecture code
The code we’ll look at in lecture is available at the beginning of lecture in a public Git repository. Here’s how to obtain it the first time:
This will put the lecture code in a directory called
To update lecture code for a new lecture, change into that directory and run
Obtaining and submitting problem sets
We will be distributing and collecting problem sets using git and code.seas.harvard.edu.
Obtaining problem sets
Getting the problem set repo
The following only needs to be done once.
First, you'll need to clone the psets repo on code.seas:
- Go to https://code.seas.harvard.edu/cs61/cs61-psets. Login to code.seas if necessary.
- Click the "Clone repository" button.
- This takes you to a new page, which gives you a chance to name your repository clone. Keep the suggested name (username-cs61-psets). Click the orange “Clone Repository” button.
Once your repository is created, you’ll be at a page that contains information about your new repository. You’re going to need the “Clone & push url” in a minute, so either copy the URL, or figure out how to get back to this page.
Next, make sure that the CS61 staff can view your repository.
- On the right sidebar, click the "Manage collaborators" button.
- On the right sidebar, click the "Add collaborators" button.
- Click the "Add a team" tab, and add "cs61-staff". Be sure to give the cs61-staff team permissions to at least view and review (and commit, if you want), before clicking the orange "Add as collaborator" button.
Next, you'll need to get a local copy of the repo on your machine:
- Launch your VM and open up a terminal.
- Configure your git "identity":
git config --global user.name "FIRST_NAME LAST_NAME" git config --global user.email "YOUR_@COLLEGE_EMAIL"
- Execute the following command:
git clone REPO_URL
REPO_URL is the "Clone & push url" from step 4.
- You will have a new folder called "username-cs61-psets", in which will be a subdirectory for the first problem set (and in the future, later problem sets).
Obtaining future problem sets
The following should be done every time a new pset is released or an old pset is updated.
- Launch your VM and open a terminal.
- Navigate to your "username-cs61-psets" directory.
git pull git://code.seas.harvard.edu/cs61/cs61-psets.git master
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://code.seas.harvard.edu/cs61/cs61-psets.git
Now you can:
- Fetch and merge new code with
git pull handout master
- Compare the handout code with your code with
git diff handout/master
Submitting problem sets
Be sure that
git status (from your "username-cs61-psets" 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
git status reports that you have uncommitted changes, you'll need to commit these changes! Read through our Git tutorial for details.
git push, and be sure Git reports that everything is up-to-date:
$ git push Everything up-to-date