CPSC 457: Operating Systems

Professor Carey Williamson

Fall 2008

Assignment 3 Tips

Here are some tips for Assignment 3.

First, it is worth re-reading the Assignment 2 tips for general advice and information about UML (still very relevant for this assignment!).

Second, it is worth looking at the Useful Links page for a very useful example about Linux Process Memory Details.

Third, it is worth looking at the /proc pseudo-filesystem to see what you can learn about processes. For example, "cat /proc/PID/maps" provides detailed memory usage information about a running process PID. You will need to gather information like this from inside the kernel.

Finally, here are some specific files you might want to know about:
    /tmp/YOURNAME/uml/linux/include/linux/mm_types.h     (for definitions of mm_struct and vm_area_struct)
    /tmp/YOURNAME/uml/linux/include/linux/mm.h     (for routines involving paging and user page tables)
    /tmp/YOURNAME/uml/linux/include/linux/sched.h     (for definition of for_each_process() macro)
    /tmp/YOURNAME/uml/linux/kernel/fork.c     (for routines like do_fork(), copy_process(), allocate_mm(), and free_mm() )
    /tmp/YOURNAME/uml/linux/kernel/exit.c     (for routines like exit_mm() )
    /tmp/YOURNAME/uml/linux/kernel/sched.c     (main CPU scheduler routines from Assignment 2)
    /tmp/YOURNAME/uml/linux/kernel/cpu.c     (for an example using for_each_process() and some locking)
    /tmp/YOURNAME/uml/linux/kernel/mutex.c     (for definition of mutual exclusion locks)
    /tmp/YOURNAME/uml/linux/kernel/spinlock.c     (for definition of spinlock routines)

One good starting point is to have the do_fork() function in fork.c or the schedule() function in sched.c print out a message whenever it sees a new process owned by you. For example, use "printk()" to show the address of the text (code) segment, data segment, heap segment, and stack segment. Set this up, boot the kernel, and see what happens when you log in.

Then think of adding a system call that collects similar information about a larger set of processes on the system. (Hint: you probably don't want to use printk() for this anymore!)