CS 439: HW 3

Due: 7:45 AM. Fr. Sep. 21

Turn-in Instructions

  1. When executing system or library calls from multi-threaded code, it is important to know which calls are re-entrant and which are not.
    1. What is the meaning of re-entrant?
    2. How does a re-entrant call behave differently from a call that is not re-entrant?
    3. Why is this an important consideration for multi-threaded code?
    4. What's the difference between a thread-safe implementation and one that's re-entrant?
  2. For the program given below, do the following twice
    Once without optimization level (No -O flag)
    Again using optimization level -O3
     
    1. Compile the program to assembler source (gcc -S)
    2. Copy/paste the assembler listing for the code in main
    3. Analyze the assembler code and determine whether or not it will load/store x each time through the loop (or not.)
      Show your answer.
    // volatile
    int x=0;
    
    int main() {
      while (x==0) {}
      return 0;
    }
  3. Repeat #2, but this time, uncomment the line:
    //volatile
  4. For each of these architectures:
    1. List all their atomic instructions.
    2. List all their memory barrier instructions.
    3. Give an example of how to use one atomic instruction.