Comp111 - Quiz 1

Oct 2, 2013 - closed book


ECE/CS Linux Login:______________

Please fill in the blanks. Each blank is worth 5 points. Blanks with the same number have the same answer.

  1. After the code fragment:
    FILE *f = fopen("foo", "r"); 
    the program's standard ________1________ is connected to the contents of ________2________.
  2. In the call
    fd represents a(n) ________3________ of two ________4________, where ________5________ is the write side.
  3. The call:
    FILE * f = fdopen(d, "w") 
    associates the ________6________ d with the file ________7________ f.
  4. malloc is a(n) ________8________ function while brk is a(n) ________9________ that malloc calls. In like manner, printf calls ________10________. In this case, buffering is used to ________11_________ the number of times that it is called.
  5. A process cannot block except when executing a(n) ________12_______, and cannot exit of its own choice unless it is ________13________.
  6. The fork system call produces two almost identical copies of the same ________14________. They differ only in the ________15________ of fork. By contrast, execl replaces the current process with a new one, while preserving ____________16____________.
  7. The manner in which one alternates executing processes is called a(n) ________17________ switch. This is usually accomplished by the ________18________.
  8. The code:
    int foo (int i) { return 2*i; } 
    typedef int (*bar)(int); 
    bar none; 
    makes ________19________ a pointer to function. To make this an alias for foo, one would write ________20________.
  9. (Extra credit) In the code immediately above, the lines ________21________ can appear in a header file, while the others cannot.