Comp111 - Quiz 1 Review 1 Answers

Oct 6, 2009 - closed book



Please fill in the blanks. Each blank is worth 5 points.

  1. The condition in which two processes are waiting for each other is called ________deadlock/mutual blocking________.
  2. In a virtual memory hierarchy, disk is used because it is ________cheaper________ and ________larger________ and ________more persistent/slower/etc________ than cache.
  3. In the code:
    if ((pid1=fork())) { 
        FILE *write = fdopen(fd[1],"w"); close(fd[0]); 
        fprintf(write, "hi there!\n"); 
        fflush(write); fclose(write); 
        pid2=wait3(&status, 0, &usage); 
        printf("exit code for %d is %d\n", pid2, status); 
    } else { 
        FILE *read = fdopen(fd[0],"r"); close(fd[1]); 
        fgets(buf,1024,read); fclose(read); 
        printf("child %d got: '%s'\n", getpid(),buf); 
    The top clause is executed by the ________parent________ while the bottom clause is executed by the ________child________ process. fd[0] is called a ________file descriptor________ while read is called a ________file pointer________ If the fflush and fclose(write) calls are omitted from the top clause, the program will ________deadlock________. At the end of both clauses, pid1 and pid2 will be ________equal________.
  4. Consider the code:
    void (*oldhandler)(int); 
    ________struct sigaction________ nu,old; 
    nu.mask=0; // don't block any
    nu.flags=0; // nothing special
    sigaction(SIGINT, &nu, &old); 
    registers a signal handler that says to call ________signal handler 'handler'________ when the user types the character ________control-C________. In the code, &old has the type ________struct sigaction *________.
  5. Operating systems would not be so interesting a subject if ________context switches________ and ________I/O________ took no time at all. The fact that these take time means that there is no ________best/perfect/ideal________ solution to balancing performance metrics such as ________throughput________ and ________response time________.
  6. A thread is also called a ________lightweight________ process.