Projects‎ > ‎

Project03

Exploring and Modifying xv6

Due Tuesday, November 8th at 11:59pm. Turn into your Project03 git repo.


For this project you are going to explore the xv6 source code, get familiar with building and running xv6, running xv6 with gdb, adding user programs to xv6, adding new system calls, and modifying the xv6 kernel.

Setting up your project03 Github repo

You will want to seed your project03 Github repo with a fresh copy the xv6 source code. After you clone your repo:

$ git clone https://github.com/USF-CS326-F16/project03-<username>.git

You can copy the xv6 source into your local repo. You want all the top level files (non dot "." file) plus these dot files:

.dir-locals.el 
.gdbinit.tmpl 
.gitignore

Make sure you do not copy the ".git" directory to your repo.

For example, if you have a fresh copy xv6-public in ~/git/xv6-public and your repo is in ~/git/projec03-<usernmae> you can do the following:

$ cd ~/git/xv6-public
$ cp * ~/git/project03-<username>
$ cp .dir-locals.el .gdbinit.tmpl .gitignore ~/git/project03-<username>
$ cd ~/git/project03-<username>
$ git add *
$ git add .dir-locals.el .gdbinit.tmpl .gitignore
$ git commit -m "Initial commit of fresh xv6 source code."
$ git push

Now you will have populated you local and Github repo.

Setting up a Build and Test Environment on the RPi

You need to following the instructions given here:


You should be able to compile xv6, run xv6 in qemu, and debug xv6 using qemu and gdb.

Debugging with GDB

For this part of the project, you need to demonstrate that you can effective use gdb or cgdb to debug the xv6 kernel.

During interactive grading you will need to show to set a breakpoint in piperead(), then execute the following command in the xv6 shell:

$ echo hello world | wc

In gdb (or cgdb) you should be able to show that the string "hello world" is in the pipe buffer.


Porting usfgrep to xv6

For this problem you need to port your implementation of usfsort to xv6.

You will need to do a few things to get this to work:
  • Get your usfsort working if it is broken for any reason
  • Port your usfsort so that it uses xv6 system calls and library calls (look at the existed xv6 user programs as a guide)
  • Figure out how to add a new user program to the xv6 filesystem (you will have to modify the Makefile to get this to work)
Once added, you need to demonstrate that usfsort works in xv6:

$ cat > hello.txt
world
hello
^D
$ usfgrep hello hello.txt
hello.txt[2] hello
$

Adding a New System Call to xv6

For this problem you need to add a new system call to the xv6 kernel and write a new xv6 user program to demonstrate that it works.

The system call you are going to add is called 

int pipe_count(int fd)

This system call will return the number of bytes currently in a pipe pointed to by fd. The fd value can be either the read end or the write end of the pipe.

In addition, if fd is not a valid pipe, you need to return -1.

Write a new user program, pipetest, that tests your pipe_count() system call.

Your test should invoke pipe_count() in the following situations:
  • The pipe is empty
  • The pipe is full
  • The pipe is in between empty and full
  • The fd is not a valid pipe

Implement halt for xv6


There is not a good way to shutdown xv6 running in Qemu. You are going to add a sys_halt() system call to xv6 and write a halt user-level program that calls sys_halt() in order to shutdown the OS and emulator. In order to do this you will need to figure out (Google) the proper instruction sequence that needs to be sent to Qemu.

Implement ps for xv6


Current, xv6 lacks a ps program to list the current running processes. You need to implement the ps user-level program and any system calls need to support ps. For each active process the output of ps should show the PID, the command, the state, and the amount of memory used.


Extra Credit

Each worth one point.

TBD

Comments