Skip to main content Link Menu Expand (external link) Document Search Copy Copied

pthread

Read pthread.c carefully. Then, run make and run pthread multiple times and observe its output. Answer the following questions based on your observations.

  1. Is the program’s output the same each time it is run? Why or why not?

  2. Based on the program’s output, do multiple threads share the same stack?

  3. Based on the program’s output, do multiple threads share the same global variables?

  4. Based on the program’s output, what is the value of void *threadid? How does this relate to the variable’s type (void *)?

  5. Using the first command line argument, create a large number of threads in pthread. Do all threads run before the program exits? Why or why not? Note: Please be precise. Vague responses will not be given credit.