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 in results/answers.md
.
Q1: Is the program’s output the same each time it is run? Why or why not?
Q2: Based on the program’s output, do multiple threads share the same stack?
Q3: Based on the program’s output, do multiple threads have separate copies of global variables?
Q4: Based on the program’s output, what is the value of
void *threadid
? How does this relate to the variable’s type (void *
)?Q5: 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?
Next up: pthread_words.