HW3: xv6 hello world

This homework teaches you to implement a simple "Hello world!" program for the xv6 OS, and helps you to better understand how the kernel address space is constructed. Since you program the xv6 operating system, you should use the same setup as for the HW2: Xv6 boot.

Part One: Hello World application

Your first task is to implement a simple program for xv6 that prints "Hello world!" on the screen.

In order to make your new hello program available to run from the xv6 shell, look at how other programs are implemented, e.g., ls and wc and make appropriate modifications to the Makefile such that the new application gets compiled, linked, and added to the xv6 filesystem.

When you're done, you should be able to invoke "hello" from the shell:

init: starting sh
$ ls   
.              1 1 512
..             1 1 512
zombie         2 17 12200
hello          2 18 12260
console        3 19 0
$ hello
Hello World!

Part Two: Put the kernel at 3GB

xv6 follows a 2GiB split where the userspace applications occupy lower 2GBs (0-2GBs) of the virtual address space and the kernel resides in the higher address (2GiB and above).

Your second task is to modify the 2GiB split such that the kernel should occupy the last gigabyte of the address space, i.e., be linked and loaded at 3GB and above, and the user programs reside in 0-3GB of the virtual address space.

When you're done, you should be able to verify the address shift with gdb:

gdb$ b main
Breakpoint 1 at 0xc0102e60: file main.c, line 19.
gdb$ c
The target architecture is assumed to be i386
=> 0xc0102e60 
: lea 0x4(%esp),%ecx Thread 1 hit Breakpoint 1, main () at main.c:19 19 { gdb$
You can see the address that main is now linked at he 3GB and above range. After the modifications, the system should run normally as before.


Submit your answers on Canvas HW3 Hello world! as a compressed tar file of your xv6 source tree (after running make clean). You can use the following command to create a compressed tar file

vagrant@odin$ cd /vagrant/ics143a
vagrant@odin$ tar -czvf hw3.tgz xv6-public
Updated: October, 2017