Assignment 0: FAQ

  1. Naming conventions for kernel functions that handle system calls:
    As it says in the handout, the function signatures given are the user-level system call functions (i.e., what a user-level function calls).
    Consider the reboot() system call:
    In src/include/unistd.h you will find the prototype "int reboot(int code)". This is the C-library function that a user-level program (like src/sbin/reboot/reboot.c) will call.
    On the kernel side, you will find a "case" in src/kern/arch/mips/mips/syscall.c for SYS_reboot - the numeric code associated with the reboot() system call. This case is handled by calling the kernel's sys_reboot() function, prototyped in kern/include/syscall.h and implemented in kern/main/main.c
    Now consider the _exit system call. You CAN call your kernel function that handles the _exit() system call _exit() as well, but it would be confusing. (The compiler will figure it out, but humans reading and discussing your code with you will have trouble with it). The convention is to pre-prend the string "sys_" to the name of the system call for the system-level handler for each user-level call. (So, reboot() on the user side is handled by sys_reboot() on the user side).
  2. What do we do with the code passed to exit?
    Nothing, right now. Just make sure it gets passed down to the existing kernel function that the assignment handout refers to, and you have a DEBUG statement there to print it out. We WILL be using this code in the next assignment.
  3. I'm getting lots of weird errors and warnings when compiling my simple_syscalls.c file. They seem to be related to including headers like lib.h
    If you are seeing things like "warning: data definition has no type or storage class", then you have probably included some kernel header without first including types.h The "types.h" file defines a LOT of structs and types that are used throughout the kernel. Without those definitions in place, you will indeed gets lots of errors. Look at the "#include"s at the start of other kernel source code files - they all start with including types.h.


Last modified: Sun Jan 21 12:38:27 EST 2007