Setting Up a Development Environment

To participate in the lab sessions (and the coding exams), you need a development environment where all necessary tools are installed. This page documents several options for a working setup.

Option 1: Web-based VS Code IDE

A first, and certainly the simplest, option is to use the web-based development environment we provide at https://code.os.cs-edu.be/. This gives you a web interface to Visual Studio Code running on an Ubuntu Linux container that has all required tools installed.

:information_source: To access the web IDE, simply login with your KU Leuven credentials. Speak to a teaching assistant if you cannot login at the URL above, as this will be required for the exam!

You should make sure to familiarize yourself with Visual Studio Code, and with using the terminal from within Visual Studio Code. Visual Studio Code is one of the most popular code editors, and is very well documented: https://code.visualstudio.com/

:bulb: With this option, you do not need to install anything on your own computer. All the tools, including the Visual Studio Code editor are pre-installed on a remote machine that you can simply access through your browser.

Opening a Terminal in VS Code

To open a terminal within Visual Studio Code, in your web browser, proceed as in the screenshot below. This provides you access to an interactive bash terminal on the underlying Ubuntu GNU/Linux container.

Open a terminal in VS Code

Cloning the xv6 repository

You can now clone the xv6 repository by running the following command:

git clone https://gitlab.kuleuven.be/distrinet/education/operating-systems/kul-xv6.git xv6

This will clone the repository into a new directory called xv6.

:bulb: Note that when using Firefox, it may be necessary to enable dom.events.testing.asyncClipboard in about:config for pasting from the clipboard to work in VS Code.

Opening the xv6 directory

To enter this directory, click the “Open Folder” button on the left, and select the xv6 directory, as shown below.

Open a folder in VS Code

Compiling and Running xv6

Compile and run the xv6 operating system in a RISC-V emulator by typing make qemu in the VS Code terminal, as shown in the screenshot below.

Run xv6 in VS Code

If the compilation is successful, the xv6 shell will automatically start in the current shell. You will see the following message:

xv6 kernel is booting

init: starting sh
$

Close the xv6 shell using the keyboard combination CTRL+A x.

:bulb: CTRL+A x != CTRL+A+x. First, press CTRL+A, release it, and then press x.

Option 2: Run the VS Code Web IDE on Your Own Computer

You can also run our container locally on your own machine. For this you will have to install Docker or Podman (e.g. via WSL). This is well documented online. Once you have a working installation, try running the following command:

docker run -it --init -p 3000:3000 -v "xv6-workdir:/home/student" registry.gitlab.kuleuven.be/distrinet/education/operating-systems/os-tools/code-server:latest

You can now proceed to compile and run xv6, as explained above.

Option 3: Setup a Custom Development Environment

A last option is to use your own computer. In that case you need to make sure that you have an up-to-date Ubuntu 24.04 distribution. There are many different ways in which you can install such an environment:

  • You can have Ubuntu 24.04 as your main operating system.
  • On Windows 10 and 11, you can install the Windows Subsystem for Linux.
  • You can install virtualization software like VirtualBox and run Ubuntu 24.04 in a virtual machine.

Once you have an Ubuntu environment, make sure to have all required tools installed, by typing:

sudo apt -y update
sudo apt -y install build-essential git gdb-multiarch qemu-system-misc \
 gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu

You can now proceed to compile and run xv6, as explained above.

:warning: We do not provide support for this third option, but we can help out on a best-effort basis if you get stuck. Importantly, you should make sure to also test and familiarize yourself with the “official” web-based IDE setup, as this is the environment you will have to use during the coding exams.

Known issues

We are transitioning away from the Microsoft C++ Tools extension to clangd due to both licensing and performance issues.

  • Changes to support clangd were pushed to the xv6 repository, and we should have updated your cloned repository already. If not, you might need to git pull yourself to merge changes. Auto-completion will be fully functional only after running make qemu at least once to generate the compile_commands.json file.
  • Note that clangd may try to auto-complete with functions from the kernel in userspace programs, and automatically include headers. However, this is not allowed, and can lead to errors when linking. Make sure you don’t include kernel/defs.h in a userspace program. Other headers, such as kernel/types.h, are okay to include in userspace programs.
  • When using the debugger, you may encounter a warning saying that a task has failed. We are still investigating this issue, but the warning should be harmless, and debugging should work if you click “Debug anyway”.

This site uses Just the Docs, a documentation theme for Jekyll.