Midterm #1 Study Question Answers
  1. Name three ways in which a program executing in user mode can enter kernel mode.
      Device interupt, trap instruction, clock tick, illegal memory operation.

  2. If a process writes continuously to a pipe but no data is read, where does the data reside and what action does the kernel eventually take?
      The data resides in a buffer in the kernel's memory space. When the buffer is full, the writing process is blocked on the write operation.

  3. In what situations is vfork() a more efficient way to implement Unix process creation than fork()? Why is it more efficient?
      vfork() is more efficient if the child performs an exec() system call soon after it is created. The efficiency is due to the fact that it is not necessary to allocate memory for and copy the entire contents of the parent's data memory, as early implementations of fork() required.

  4. A program is structured using three threads: one reads input from an input file, one processes it and one writes the result to an output file. Is many-to-one or one-to-one a better thread management scheme for this program, and why?
      Shared memory is better because pipes are (by default) blocking communication which will, for instance, keep the output process from getting data if the comput process is blocked waiting for input. Shared memory allows for more fine-grained communication and synchronization.