The Structure of Processes

Monday, September 27

We explored the ramifications of the Unix design choice to have all code, both kernel and user, be executed in the context of a process.  In particular, if a process is running, it is either running in user mode, in which case it is executing the user's program code, or in kernel mode, in which case it is executing instructions of the kernel program.  Some issues to resolve are

  1. The user code should never be able to contain privileged instructions that get executed.  This is taken care of by the hardware feature that always sets the mode to supervisor when an interrupt is encountered.
  2. The user code should never be able to address values outside of its own text area.  In particular, the user code should never be able to address locations in the kernel address space, even though the kernel runs in the context of the currently running user process. 

Part 2 can be handled in a variety of ways.  One is for the operating system to ensure that different page table and page table register contents are set for user and supervisor mode execution.  Another is to turn off virtual memory management when running in kernel mode and have the kernel run from fixed physical locations.  The operating system would then, of course, ensure that all virtual addresses of user code would be mapped to areas beyond the section of RAM reserved for the OS.

To be sure we understood these possibilities we reviewed how virtual memory works in terms of both hardware and software, and also reviewed the concept of associative memory and a translation lookaside buffer (TLB).