Comp111 - Quiz 1

Oct 3, 2018 - closed book



Please fill in the blanks. Each blank is worth 5 points. There are several reasonable answers for some of the blanks; choose one. Blanks with the same number have the same answer.

  1. A difficulty in assignment one is that many system calls cannot be repeated a large number of times, because a different system call must be called between each two calls of the same function. For example, a call to ________1_________ must be undone by ________2_________ or a deadlock occurs the next time the former is called.
  2. During an exec, all ________3_________ is replaced, and the only things that are preserved are the open ________4________ and the ________5________ variables for the process. In particular, it is impossible to institute a signal ________6_________ before an exec and have it apply to the process after the exec.
  3. A pipe is logically a set of two connected ________7_________ represented as an array of integers int p[2];. Once the pipe is initialized, one writes to p[________8________] and reads from p[________9________]. To write to a pipe as if it were a terminal or file, one uses the library function ________10_________ to make fprintf work on the pipe. The differences between write and fprintf include that write acts on a file ________11________ while fprintf acts on a file ________12________. While write always happens ________13________, fprintf is ________14________ and must be ________15________ to ensure that everything is written.
  4. The reason that fork and exec are different calls is that one often wants to make changes in process settings ________16_________ executing the forked process.
  5. In advanced C, typedefs allows one to define shorthands for complex types. For example, after writing typedef int foo[10]; the typedef declaration ________17________ declares an array bar with 10 elements. A typedef cannot be ________18_________ in the same file.
  6. A C pointer to function is used in defining signal ________19_________ that describe what to do when the signal is received.
  7. A C pointer passed to a function allows the function to ________20_________ the storage where it points.
  8. (Extra credit) In assignment 1, people reported that even pure system calls accumulate a little bit of user time. This is because each system call is implemented via a ________21______ in that actually invokes the kernel function.