This is not the current version of the class.

# Lecture 6

What potential bug was addressed by commit d12e98cdb959bb9cdb85fc8e1b0878733026388e? Describe a possible execution of the old code that could violate some kernel invariant or otherwise cause a problem.

## syscall registers

The syscall entry point saves most registers to a struct regstate. But is that really necessary? For instance, the callee-saved registers, such as %rbx and %r12, will be saved and restored by kernel C++ code automatically, since the C++ compiler uses the normal x86-64 calling convention. (For this reason, syscall_entry doesn’t bother to restore those registers when it resumes the user process!)

Which registers must syscall_entry save to struct regstate for Chickadee to work correctly? Run experiments to see, and explain the results.

## ucontext

On Linux or Mac, read the manual pages for getcontext, setcontext, makecontext, and swapcontext. What are the closest-corresponding Chickadee functions? Roughly how will these functions be implemented? Which of them, if any, can be implemented entirely within the C abstract machine (as opposed to using assembly)?

## Exit design

Problem Set 2, Part B asks you to implement part of a sys_exit system call. One of the invariants mentioned says that “The kernel task responsible for the exiting process must delegate its final freeing to some other logical thread of execution”. Come up with an initial design for this delegation.