TI-RTOS for SimpleLink Wireless MCUs
2.14.02.22
|
Mutex module for the RTOS Porting Interface.
============================================================================
The MutexP module allows task to maintain critical region segments. The MutexP module has two main functions: MutexP_lock and MutexP_unlock.
The MutexP module supports recursive calls to the MutexP_lock API by a single task. The same number of MutexP_unlock calls must be done for the mutex to be release. Note: the returned key must be provided in the LIFO order. For example:
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | MutexP_Params |
Basic MutexP Parameters. More... | |
Typedefs | |
typedef enum MutexP_Status | MutexP_Status |
Status codes for MutexP APIs. More... | |
typedef void * | MutexP_Handle |
Opaque client reference to an instance of a MutexP. More... | |
typedef struct MutexP_Params | MutexP_Params |
Basic MutexP Parameters. More... | |
Enumerations | |
enum | MutexP_Status { MutexP_OK = 0, MutexP_FAILURE = -1 } |
Status codes for MutexP APIs. More... | |
Functions | |
MutexP_Handle | MutexP_create (MutexP_Params *params) |
Function to create a mutex. More... | |
MutexP_Status | MutexP_delete (MutexP_Handle handle) |
Function to delete a mutex. More... | |
void | MutexP_Params_init (MutexP_Params *params) |
Initialize params structure to default values. More... | |
uintptr_t | MutexP_lock (MutexP_Handle handle) |
Function to lock a mutex. More... | |
void | MutexP_unlock (MutexP_Handle handle, uintptr_t key) |
Function to unlock a mutex. More... | |
typedef enum MutexP_Status MutexP_Status |
Status codes for MutexP APIs.
typedef void* MutexP_Handle |
Opaque client reference to an instance of a MutexP.
A MutexP_Handle returned from the MutexP_create represents that instance. and then is used in the other instance based functions (e.g. MutexP_lock, MutexP_unlock, etc.).
typedef struct MutexP_Params MutexP_Params |
Basic MutexP Parameters.
Structure that contains the parameters are passed into MutexP_create when creating a MutexP instance. The MutexP_Params_init function should be used to initialize the fields to default values before the application sets the fields manually. The MutexP default parameters are noted in MutexP_Params_init.
enum MutexP_Status |
MutexP_Handle MutexP_create | ( | MutexP_Params * | params | ) |
Function to create a mutex.
params | Pointer to the instance configuration parameters. NULL denotes to use the default parameters. The MutexP default parameters are noted in MutexP_Params_init. |
MutexP_Status MutexP_delete | ( | MutexP_Handle | handle | ) |
Function to delete a mutex.
handle | A MutexP_Handle returned from MutexP_create |
void MutexP_Params_init | ( | MutexP_Params * | params | ) |
Initialize params structure to default values.
The default parameters are:
params | Pointer to the instance configuration parameters. |
uintptr_t MutexP_lock | ( | MutexP_Handle | handle | ) |
Function to lock a mutex.
This function can only be called from a Task. It cannot be called from an interrupt. The lock will block until the mutex is available.
Users of a mutex should make every attempt to minimize the duration that that they have it locked. This is to minimize latency. It is recommended that the users of the mutex do not block while they have the mutex locked.
This function unlocks the mutex. If the mutex is locked multiple times by the caller, the same number of unlocks must be called.
handle | A MutexP_Handle returned from MutexP_create |
void MutexP_unlock | ( | MutexP_Handle | handle, |
uintptr_t | key | ||
) |
Function to unlock a mutex.
This function unlocks the mutex. If the mutex is locked multiple times by the caller, the same number of unlocks must be called. The order of the keys must be reversed. For example
handle | A MutexP_Handle returned from MutexP_create |
key | Return from MutexP_lock. |