TWiki> CS385fall14 Web>Homeworks>Homework1 (revision 7)EditAttach

Homework 1: lots of tools, and a simple program

In this homework, we primarily familiarize ourselves with a number of tools we'll be using throughout the semester. Partial credit is hard to get in this homework - in order to get something running, and manage to submit the homework on time, you probably have to get it all right, so please get started early as there are many stumbling blocks along the way.

The instructions below are very minimal. Expect to have to do some googling along the way to figure out how to get things to work on your end. For a great manual of git, see Make sure to read sections 1-3 to get a good understanding of its operation.

Set up a Linux environment

For this class, you need access to a Linux machine. It is convenient if your laptop is running Linux natively, but many other solutions will work as well. You do not need a linux GUI for this class, so you can use a remote Linux server if you need to. You do need to run xv6 in a VM on your local machine, however. If you do not own a suitable computer, you may use the CS computer labs in SEL. Let me (Jakob) know, as this may take a little extra doing.

Install qemu on your machine

Qemu is a PC emulator we'll be using to run xv6 under. In linux (Ubuntu), apt-get install qemu should do it. On a mac, install Macports, then port install qemu.

Get the xv6 sources, build (under Linux) and run (under Linux or elsewhere)

On your Linux machine, first install git: apt-get install git. Then fetch the version of the xv6 source tree that is hosted at UIC:

git clone

This creates a directory xv6 which contains all the sources. To build xv6, you need a toolchain: compiler, linker, and such. To get the basics, apt-get install build-essential. Now, you should be ready to build and run xv6 under qemu: make qemu.

note: If you are using a Linux machine to build xv6, and a Windows or OS X machine to run xv6 within qemu, there is an extra step involved. First build xv6 make xv6.img, then run it on your machine. On OS X, say qemu-system-i386 -m 512 -hdb fs.img xv6.img. Not sure how it goes on Windows, but should be quite similar.

Create a git branch for hw1

In the xv6 folder, create and check out the branch git checkout -b hw1.

Write an 'uptime' program for xv6

xv6 comes with a number of small programs, like ls and cat. You are to create a new program, uptime, which outputs the number of hours, minutes and seconds that xv6 has been running, in the format hours:minutes:seconds. There is a handy wrapper function uptime() for the uptime system call, which you may use.

The program should be called uptime.c, and typing make qemu should automatically build the uptime binary just like it builds the other binaries. Running the command uptime in qemu should produce an output like:

current uptime is 00:03:43

Commit your work in a git branch called hw1

Stage your modified and added files git add Makefile uptime.c, and commit your staged files git commit -m "Homework 1, first attempt".

Create and submit verified homework patch

Finally, prepare and submit a patch with the differences between the original and your hw1 branch to our TA Sepideh using email. git format-patch origin --stdout > hw1.patch.

To check that your submission is correct, first switch to the master branch git checkout master, then apply your patch git apply hw1.patch and try it out by building and running: make qemu and finally running your uptime program from inside xv6. When you've verified that all is well, git reset to clean up your temporary changes to the master branch.

Once you have a correct patch file, send this file as an attachment to Submission is due before beginning of class, Tuesday Sept 2.

Edit | Attach | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r7 - 2014-08-27 - 13:14:40 - Main.srogha2
Copyright 2016 The Board of Trustees
of the University of
Helping Women Faculty Advance
Funded by NSF