Real-Time Embedded Multithreading: Using ThreadX and ARM

The mutex services described in this appendix include:
| tx_mutex_create | Create a mutual exclusion mutex |
| tx_mutex_delete | Delete a mutual exclusion mutex |
| tx_mutex_get | Obtain ownership of a mutex |
| tx_mutex_info_get | Retrieve information about a mutex |
| tx_mutex_prioritize | Prioritize the mutex suspension list |
| tx_mutex_put | Release ownership of a mutex |
Create a mutual exclusion mutex
UINT <b class="bold">tx_mutex_create</b>(TX_MUTEX <b class="bold">*mutex_ptr,</b> CHAR <b class="bold">*name_ptr,</b> UINT <b class="bold">priority_inherit</b>)
This service creates a mutex for inter-thread mutual exclusion for resource protection. This service initializes the Mutex Control Block through the parameter mutex_ptr.
| mutex_ptr | Pointer to a Mutex Control Block. |
| name_ptr | Pointer to the name of the mutex. |
| priority_inherit | Specifies whether or not this mutex supports priority inheritance. If this value is TX_INHERIT, then priority inheritance is supported. However, if TX_NO_INHERIT is specified, priority inheritance is not supported by this mutex. |
| TX_SUCCESS 1 | (0x00) | Successful mutex creation. |
| TX_MUTEX_ERROR | (0x1C) | Invalid mutex pointer. Either the pointer is NULL or the mutex has already been created. |
| TX_CALLER_ERROR | (0x13) | Invalid caller of this service. |
| TX_INHERIT_ERROR | (0x1F) | Invalid priority inheritance parameter. |
[84]
This value is not affected by the TX_DISABLE_ERROR_CHECKING define that is used to disable API error checking.
Initialization and threads
No
TX_MUTEX my_mutex;UINT status;/* Create a mutex to provide protection over a common resource. */status = <b class="bold">tx_mutex_create</b>(&my_mutex,"my_mutex_name", ...