Posix API Labs
Posix API Labs
Posix API Labs
system development
Training lab book
Setup
Go in the /home/<user>/felabs/sysdev/posix/ directory, the
recommended location to store your lab files.
Threads
To start, create a simple application that runs two threads, each
printing a different message indefinitely, by using pthread_create()
and compiling with lpthread. What happens when you run the
program ?
The main() function exits as soon as the two threads are created. You
need to join the threads in order to wait for their completion, using
pthread_join(). Do it and try again the application.
Now, change the code so that the two threads increment the same
global counter 1.000.000 times, and display the value of the global
counter at the end. What happens ?