All the documentation I\'ve read on the pthreads mutex states only that a mutex prevents multiple threads from accessing shared memory, but how do you specify in the program
When locked, a mutex prevents any other thread from obtaining a lock on that same mutex. So, if you want some particular data to be thread safe (i.e., a critical section of memory), you should obtain a lock on the mutex before reading from it or writing to it, then release the lock when finished. The mutex itself does not refer to any particular section of memory. It is simply a tool you can use.