This quiz checks your comprehension of the reading assignments and material presented in class. It covers lectures from 9/17 through 9/26. You may reference the textbook, lecture slides, and your notes. Online sites (e.g., Wikipedia) may also be consulted but you must cite them in your writeup.
Each question is worth three points. Please strive for clarity and brevity in your answers. Essay questions should require no more than one or two short paragraphs. Pseudo-code should be in the form of short descriptive English statements.
Submit your answers by clicking the "submit" link on the lecture schedule page. Only online submissions will be accepted. Please submit plain ASCII text files.
# A generic library call
int foo (void *arg1, void *arg2, ..., void *argn) {
int result;
move arg1 to R_1;
move arg2 to R_2;
...
move argn to R_n;
move FOO to R_0;
# Trap to kernel
int $0x80;
move R_result to result;
return result;
}
--- User - kernel boundary ---
# The currently running process
Process *current;
# Array of system call handler functions
typedef int (*SYSCALL_HANDLER)(void);
const SYSCALL_HANDLER sysent[] = {
handler1,
handler2,
...
handlerN
}
# The syscall entry point in the kernel
void syscall_entry(void) {
SYSCALL_HANDLER handler;
int index, result;
save_context(current);
use_kernel_stack(current);
# Look up system call handler
move R_0 to index;
handler = sysent[index];
# Call it. We're assuming args are still in registers...
result = handler(void);
move result to R_result;
use_user_stack(current);
restore_context(current);
# Switch to user mode and return
iret;
}
Process *current;
void schedule(void) {
Process *next;
save_context(current);
flush_cache_and_TLB();
next = choose_ready_process();
next->state = RUNNING;
restore_context(next);
current = next;
jump_to_PC(next);
}