CS 367 HW #5
Due April 29 at classtime

  1. In linking, what is symbol resolution? What is symbol relocation?
  2. Consider the following C program. How many times will each string ("One", "Two", "Three", "Four", "Five") be output?
    fun() {
      printf("One");
      fork();
      printf("Two");
      if (fork() == 0) {
         printf("Three");
         fork();
         printf("Four");
      }
      printf("Five");
    }
    
  3. Consider the following C program. What are all of the possible outputs of the program?
    #define N 3
    int val = 10;
    void handler(sig) {
       val += 5;
       return;
    }
    int main() {
      pid_t pid;
      int i;
      signal(SIGCHLD,handler);
      for (i=0;i<N;i++) {
        if ((pid ==fork()) == 0) {
            val -= 3;
            exit(0);
        }
      }
      for (i=0;i<N;i++) {
        waitpid(-1,NULL,0);
      }
      printf("val = %d\n",val);
    }
    
  4. In your text, 8.8 (p. 639)
  5. In your text, 8.14 (p. 641-2)