Jan Fan     About     Archive     Feed     中文博客

How I Learn OS With xv6

Operating System is one of core courses for CS students. I have spent a lot of time trying to learn it well, and here I want to share my experience with you guys.

AFAIK, it's impossible to learn OS well without reading the source code. We'd better start with the earlier version of OS, since the modern ones are so huge that one can hardly read them.

And my choice - xv6, Unix Version 6. What makes it special is that MIT has open an OS course on it, giving lots of materials to help students better understand it.

MIT 6.828 OS Engineering Course

Hereafter I'm going to write series of articles helping you to learn this corse more easily.

!--more--

Setting up the environment for xv6

Virtual Machine

Compiling the xv6 source code requiring GNU toolchain(you surely need to debug it for deeper understanding of the OS, and besides MIT cource has prepared brilliant homeworks and labs for you).

If you are using Windows or OS X, I strongly recommend you to do the work on Virtual Machine. It will save your life (Not my life...I spent days and nights configuring the toolchains, and eventually failed).

VirtualBox is one of your good choices. Personally I use Ubuntu 12.04 64-bit(apt-get is really charming if you have ever used it before). You can use any distributions of Linux, but I will take Ubuntu for example in this tutorial.

GNU Toolchains and Others

sudo apt-get update
sudo apt-get install build-essential

build-essential is a package for developers. It contains most of the tools you will need during your code work, like gcc, g++, gdb, objdump and etc.

sudo apt-get install gcc-multilib

This lib is required for the multi-thread support.

sudo apt-get install qemu

qemu is a computer simulator in which the xv6 kernel is going to run.

sudo apt-get install git-core

Git, a must-have, no need to explain it.

Now the Toolchains is done. You can

xv6 source code

mkdir ~/6.828
cd 6.828
git clone git://pdos.csail.mit.edu/xv6/xv6.git

The above will download the xv6 source code for you. You can then do the following to boot xv6 up.

cd ~/6.828/xv6
make
make qemu

See? A ugly console, but you will get to know how subtle it is behind the black window

Labs in MIT 6.828

cd ~/6.828
git clone http://pdos.csail.mit.edu/6.828/2011/jos.git lab 

Download the lab materials into lab directory.

cd ~/6.828/lab
make
make qemu

After that you are going to see the black qemu window showing up. The very first small kernel in the lab is up!

Important Words

And I still have a bit of advice for you to firmly remember: Whenever errors encounter during make, do make clean first after you make changes in the source code. Or you won't get it corrent even if you have fix the code correctly.(You can imagine how crazy I got when I hadn't discovered this :()

Comments

comments powered by Disqus