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


tis_mutex_init

Initializes a mutex.

Syntax

tis_mutex_init(
               mutex );
 


Argument Data Type Access

mutex opaque pthread_mutex_t write


C Binding

#include 

int tis_mutex_init ( pthread_mutex_t *mutex );

Arguments

mutex
Pointer to a mutex (passed by reference) which is initialized.

Description

This routine initializes a mutex with the default mutex attributes. A mutex is a synchronization object that allows multiple threads to serialize their access to shared data.

The mutex is initialized and set to the unlocked state. Mutexes can be allocated in heap or static memory, but not on a stack.

The PTHREAD_MUTEX_INITIALIZER macro can be used to statically initialize a mutex without calling this routine. Statically initialized mutexes need not be destroyed using tis_mutex_destroy. Use this macro as follows: pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

Return Values

If an error condition occurs, this routine returns an integer value indicating the type of error, the mutex is not initialized, and the contents of mutex are undefined. Possible return values are as follows:
Return        Description

0 Successful completion. [EAGAIN] The system lacks the necessary resources to initialize a mutex. [ENOMEM] Insufficient memory exists to initialize the mutex. [EBUSY] The implementation has detected an attempt to reinitialize the mutex (a previously initialized, but not yet destroyed mutex). [EINVAL] The value specified by mutex is invalid. [EPERM] The caller does not have privileges to perform this operation.


Associated Routines

   tis_mutex_lock
   tis_mutex_trylock
   tis_mutex_unlock
   tis_mutex_destroy



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