CS 439: HW 3
Due: 7:45 AM. Fr. Sep. 21
Turn-in Instructions
When executing system or library calls from multi-threaded code, it is important to know which calls are
re-entrant
and which are not.
What is the meaning of
re-entrant
?
How does a re-entrant call behave differently from a call that is not re-entrant?
Why is this an important consideration for multi-threaded code?
What's the difference between a
thread-safe
implementation and one that's
re-entrant
?
For the program given below, do the following
twice
Once without optimization level (No
-O
flag)
Again using optimization level
-O3
Compile the program to assembler source (
gcc -S
)
Copy/paste the assembler listing for the code in
main
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; }
Repeat #2, but this time,
uncomment
the line:
//volatile
For each of these architectures:
X86-64
PowerPC
List all their atomic instructions.
List all their memory barrier instructions.
Give an example of how to use one atomic instruction.