Written Component
If you're working as a pair, work together as a pair to find the answers to the questions below. You are not required to share a single machine pair-programming style, but that may be the easiest way to work on this part. You must make sure that you both know how each answer was found, have read through the relevant source file, and know why your answer is “the right answer”.
A copy of these questions is provided in the handin/written.md file in your repository. Put your answers in that file.
Questions
A: Kernel Configuration and Compilation
There are configuration files in the following places:
src/kern/conf/conf.kernsrc/kern/arch/mips/conf/conf.archsrc/kern/arch/sys161/conf/conf.archsrc/kern/dev/lamebus/conf.lamebus
These files are used to configure the kernel build process (and need to be modified if you add new files to the kernel). They also provide something of a roadmap to the kernel's structure and what different files are used for.
- Under what circumstances should you re-run the
kern/conf/configscript? - Under what circumstances should you run bmake depend in
kern/compile/DUMBVM? - Under what circumstances should you run bmake or bmake install in
kern/compile/DUMBVM? - When you booted your kernel, you found that there were several commands you could type in that you could issue to experiment with it (e.g..,
panic). Explain exactly where and what you would have to do to add a command that printed out,Hello world!
B: Low-Level Architecture-Decendent Code
- Traps are provide an entry point into the kernel from user programs. Find the code in OS/161 that handles traps. In which file and on which lines did you find this code? (Hint: The low-level nature of traps means that they're highly architecture-dependent.)
- Making a system call, such as write, ultimately leads to a trap. Find the code in OS/161 that invokes system calls from user programs and causes traps. In which file and on which lines did you find this code?
- What about interrupts?
- What are some of the details which would make a function “machine dependent”? Why might it be important to maintain this separation, instead of just putting all of the code in one function?
- How large is a trapframe? Why?
- Which register number is used for the stack pointer (sp) in OS/161?
- What is the difference between
splhighandspl0? - Why do we use typedefs like
u_int32_tinstead of simply sayingint? - What does
splxreturn? - What function is called when user-level code generates a fatal fault?
C: Threading and Scheduling
- How frequently are “hardclock” interrupts generated?
- What function puts a thread to sleep?
D: Utility Code
- Can an array represented by a
struct arraybe resized?
E: Common Code
- Why do you suppose there are libc functions in the “common” part of the source tree (
common/libc) as well as inuserland/lib/libc?
F: User-Level Programs
- We suggested you run
p /sbin/rebootto run one of the few userspace commands that “works” in OS/161 right now. Where is the code for this command? What does it do? - The Linux machine we're using also has a program
/sbin/reboot. Why do we need to build our own version of this program for OS/161? - When a user program exits normally, what is done with the program's return value?
- Why do we need to include these in your OS/161 distribution? Why can't you just use the standard utilities that are present on the machine on which you're working?
(When logged in, completion status appears here.)