Rate This Document
Findability
Accuracy
Completeness
Readability

HTL_thread_mutex_init

Initializes a mutex.

Interface Definition

int HTL_thread_mutex_init(HTL_thread_mutex_t *thread_mutex, const HTL_thread_mutexattr_t *thread_mutexattr);

Description

HTL_thread_mutex_init() uses the mutex attribute thread_mutexattr to initialize the mutex and returns the mutex handle through thread_mutex. If thread_mutexattr is set to NULL, thread_mutex has default attributes.

This function does not own thread_mutexattr. Therefore, users need to invoke HTL_thread_attr_destroy() to destroy thread_mutexattr after using this function. thread_mutex must be destroyed by HTL_thread_mutex_destroy() after being used.

Parameters

Parameter

Type

Description

Input/Output

thread_mutex

HTL_thread_mutex_t *

Address of the handle to the mutex.

Output

thread_mutexattr

HTL_thread_mutexattr_t *

Address of the handle to the mutex attribute.

Input

Return Value

  • HTL_THREAD_SUCCESS: success.
  • Other values: failure. For details, see the error code descriptions.

Example

1
2
3
4
5
    HTL_thread_mutex_t mutex;
    HTL_thread_mutexattr_t mutex_attr;
    int ret;
    ret = HTL_thread_mutexattr_init(&mutex_attr);
    ret = HTL_thread_mutex_init(&mutex, &mutex_attr);