Hints for A2


Quick Topic Links


General

  • Don't forget to re-configure your kernel for Assignment 2, and to do all of your kernel builds in kern/compile/ASST2
    % cd $HOME/cs350-os161/os161-1.11/kern/conf
    % ./config ASST2
    % cd ../compile/ASST2
    % make depend
    % make
    % make install
    

  • Don't forget that if you add any new source files to the kernel code, you need to update the file kern/conf/conf.kern and you need to reconfigure your kernel. If you don't do this, the code in your new source file will not be included in the kernel build.

  • Don't worry about trying to reclaim physical frames in the kernel when they are no longer used. However, you should make sure that you kfree kernel memory that you've allocated using kmalloc but that the kernel no longer needs.

  • You may like to have lots of debugging information printing out from your kernel, but we don't want to see mountains of output when we run your kernel. OS/161 provides a DEBUG facility that can help with this problem - you can bury lots of debugging statements into your code, and you can turn them all off by just changing the value of a single variable. You can even turn them off conditionally by labeling them properly. To use this facility, you just include DEBUG statements into your code instead of kprintf, like this:
    DEBUG(DB_EXEC, "ELF: Loading %lu bytes to 0x%lx\n", 
         (unsigned long) filesize, (unsigned long) vaddr);
    
    The DEBUG macro and the various flags (like DB_EXEC) are defined in kern/include/lib.h. To control which DEBUG statements produce output, set the dbflags variable, which is found in kern/lib/kprintf.c. For example, setting
    u_int32_t dbflags = 0;
    
    will turn off all debugging output, while
    u_int32_t dbflags = DB_EXEC|DB_THREADS;
    
    will turn off everything except DEBUG statements that are labeled with DB_EXEC or DB_THREADS.

  • write


    _exit


    passing arguments


    open, close, read, write


    fork


    testing