Comp111 - Quiz 1 Review 4

Oct 6, 2009 - closed book

Name:________________________________

Login:______________

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

  1. Suppose we have a C function
     
    struct bar *foo(const struct dog *); 
    
    and a function pointer
     
    void *(*p)(const void *); 
    
    Then we can assign the value of foo to p only via a type cast
     
    p = (________________1________________) foo; 
    
    This kind of cast is necessary for starting up a ________2________, because one wants to pass it an argument of ________3________ type.
  2. In the code
     
    pid = wait3(&status,0,&rusage); 
    
    pid is the process identifier of the last process that ________4________, while status is that process's ________5________.
  3. The command:
     
    pid = fork(); 
    
    creates two copies of a program. In the parent, pid is the identifier of the ________6________, while in the child, pid is ________7________. Failure to flush a formatted I/O output buffer before a fork can lead to ________8________ output.
  4. The command
     
    execl("/usr/bin/foo", "/usr/sbin/bar", "cat"); 
    
    does the same thing as typing ________9________ on the command line. It replaces all ________10________ memory with that contained in the new program, but leaves ________11________ memory largely alone. Among other things, the program's ________12________ variable values and I/O ________13________ are preserved after an execl.
  5. Internally, the return values from getrusage are part of the ________14________ stored in kernel memory.
  6. Thread mutexes are stored in ________15________ memory while semaphores are stored in ________16________ memory. The reason for the latter is that independent processes don't ________17________ memory.
  7. System calls take more time than regular subroutine calls because it is necessary to change the ________18________ during the call in order to access kernel data structures.
  8. The scheduler decides which process should run next. ________19________ scheduling minimizes response time for interactive applications, while ________20________ scheduling maximizes work throughput.