Copy the week 13 files:
$ cd cs31/inclass $ cp -r ~mauskop/public/cs31/week13/ .
mutex.c and barrier.c demonstrate how to use
a mutex and how to use a barrier, respectively.
# pipe cat's output through less (space to page fwd, q to quit) cat /proc/cpuinfo | less
top is a Unix utility that lists information about processes and threads and how they are using resources like memory and CPU. If you run top with no command line options, then it displays per-process statistics. If you run top with -H, top will display statistics for individual threads:
top -H
Debugging threaded programs can be tricky because there are multiple streams of execution. In general, try to debug with as few threads as possible, and if you use printfs, print out a thread id and call fflush after. You can also put printf's in conditional statements to only have one of the threads print out information (or only some of the threads, or only some of the information, ...).
More detailed information about gdb and pthreads can be found here: gdb and pthreads