TI-RTOS for SimpleLink Wireless MCUs  2.14.02.22
Data Structures | Typedefs | Enumerations | Functions
MutexP.h File Reference

Detailed Description

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:

uintptr_t key1, key2;
key1 = MutexP_lock();
key2 = MutexP_lock();

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
Include dependency graph for MutexP.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 Documentation

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.

Enumeration Type Documentation

Status codes for MutexP APIs.

Enumerator
MutexP_OK 

API completed successfully

MutexP_FAILURE 

API failed

Function Documentation

MutexP_Handle MutexP_create ( MutexP_Params params)

Function to create a mutex.

Parameters
paramsPointer to the instance configuration parameters. NULL denotes to use the default parameters. The MutexP default parameters are noted in MutexP_Params_init.
Returns
A MutexP_Handle on success or a NULL on an error
MutexP_Status MutexP_delete ( MutexP_Handle  handle)

Function to delete a mutex.

Parameters
handleA MutexP_Handle returned from MutexP_create
Returns
Status of the functions
  • MutexP_OK: Deleted the mutex instance
  • MutexP_FAILED: Failed to delete the mutex instance
void MutexP_Params_init ( MutexP_Params params)

Initialize params structure to default values.

The default parameters are:

  • name: NULL
Parameters
paramsPointer 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.

Parameters
handleA MutexP_Handle returned from MutexP_create
Returns
A key is returned. This key must be passed into MutexP_unlock.
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

1 uintptr_t key1, key2;
2 key1 = MutexP_lock();
3 key2 = MutexP_lock();
4 MutexP_lock(key2);
5 MutexP_lock(key1);
Parameters
handleA MutexP_Handle returned from MutexP_create
keyReturn from MutexP_lock.
Copyright 2015, Texas Instruments Incorporated