Ex. 1 Download and compile the program hello_world_pt.cc with the command
g++ hello_world_pt.cc -o hello -lpthreadRun the program with the command
helloRead and try to understand the program.
Ex. 2 Modify the previous program such that the parent thread is waiting for all of the others. For each thread in the array you will have to call the function pthread_join with the first argument being the thread (and not a pointer to it), and the second argument being NULL. Once all of the threads have been joined, print a message from the main to say it is done.
Ex. 3 Write a function that takes as an argument the identity of the thread and does the following:
Call this function from the function PrintHello such that it will be called by each of the threads.locks the mutex, increments the value of the shared variable, prints a message with the value of the shared variable and the identity of the thread, unlocks the mutex.
Turn in (optional, 5 extra points): the modified source file for Ex. 3. Only accepted till next Tuesday.