[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


4.1 Mutexes

Just like normal DECthreads mutexes, tis mutexes provide synchronization between multiple threads that share resources. In fact, you can statically initialize tis mutexes using the POSIX 1003.1c PTHREAD_MUTEX_INITIALIZER macro defined in pthread.h, or any of the various non-portable DECthreads variants. That means you can create recursive or errorcheck mutexes if you need them, as well as the default normal mutexes. You can assign names to your tis mutexes.

Unlike static initialization, however, dynamic initialization of tis mutexes is limited by the absence of attributes objects. The tis_mutex_init() routine can create only normal (default) mutexes.

When DECthreads is initialized, any locked mutexes remain locked. The ownership of recursive and errorcheck mutexes remains valid. That means it's legal and reasonable to lock a tis mutex, dynamically activate the DECthreads library, and then unlock the mutex.

The DECthreads global lock is implemented in tis, and you can use it without calling the DECthreads interfaces by calling tis_ lock_global() and tis_unlock_global().