SYS/BIOS
7.00
|
Mutex Gate.
GateMutex uses a Semaphore as the resource locking mechanism. Each GateMutex instance has its own unique Semaphore. This gate can only be used by a Task as a gate can potentially block. This gate cannot be used by a Hwi or Swi.
The task that uses a gate can call enter() any number of times without risk of being blocked, although relinquishing ownership of the gate requires a balanced number of calls to leave().
Function | Hwi | Swi | Task | Main | Startup |
---|---|---|---|---|---|
Params_init | Y | Y | Y | Y | Y |
query | Y | Y | Y | Y | Y |
construct | N | N | Y | Y | N |
create | N* | N* | Y | Y | N |
delete | N* | N* | Y | Y | N |
destruct | N | N | Y | Y | N |
enter | N | N | Y | N | N |
leave | N | N | Y | N | N |
Definitions:
|
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <ti/sysbios/knl/Queue.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/runtime/Error.h>
Go to the source code of this file.
Data Structures | |
struct | GateMutex_Params |
struct | GateMutex_Struct |
Macros | |
#define | GateMutex_A_badContext "bad calling context" |
Assert when GateMutex_enter() is not called from correct context. GateMutex_enter() can only be called from main() or Task context (not Hwi or Swi). More... | |
Typedefs | |
typedef struct GateMutex_Params | GateMutex_Params |
typedef struct GateMutex_Struct | GateMutex_Struct |
typedef struct GateMutex_Struct | GateMutex_Object |
typedef GateMutex_Object * | GateMutex_Handle |
Functions | |
bool | GateMutex_canBePreempted (void) |
query Gate 'preempt' characteristics More... | |
bool | GateMutex_canBlock (void) |
query Gate 'blocking' characteristics More... | |
GateMutex_Handle | GateMutex_create (const GateMutex_Params *prms, Error_Block *eb) |
Create a GateMutex gate. More... | |
GateMutex_Handle | GateMutex_construct (GateMutex_Struct *obj, const GateMutex_Params *prms) |
Construct a GateMutex gate. More... | |
void | GateMutex_delete (GateMutex_Handle *gate) |
Delete a GateMutex gate. More... | |
void | GateMutex_destruct (GateMutex_Struct *obj) |
Destruct a GateMutex gate. More... | |
void | GateMutex_Params_init (GateMutex_Params *prms) |
Initialize the GateMutex_Params structure with default values. More... | |
intptr_t | GateMutex_enter (GateMutex_Handle gate) |
enter the GateMutex gate More... | |
void | GateMutex_leave (GateMutex_Handle gate, intptr_t key) |
leave the GateMutex gate More... | |
GateMutex_Handle | GateMutex_Object_first (void) |
return handle of the first GateMutex on GateMutex list More... | |
GateMutex_Handle | GateMutex_Object_next (GateMutex_Handle gate) |
return handle of the next GateMutex on GateMutex list More... | |
#define GateMutex_A_badContext "bad calling context" |
Assert when GateMutex_enter() is not called from correct context. GateMutex_enter() can only be called from main() or Task context (not Hwi or Swi).
Common causes and workarounds for hitting this Assert:
typedef struct GateMutex_Params GateMutex_Params |
typedef struct GateMutex_Struct GateMutex_Struct |
typedef struct GateMutex_Struct GateMutex_Object |
typedef GateMutex_Object* GateMutex_Handle |
bool GateMutex_canBePreempted | ( | void | ) |
query Gate 'preempt' characteristics
GateMutex can be preempted. This API always returns true
.
true |
bool GateMutex_canBlock | ( | void | ) |
query Gate 'blocking' characteristics
GateMutex enter can block if another task owns the gate. This API always returns true
.
true |
GateMutex_Handle GateMutex_create | ( | const GateMutex_Params * | prms, |
Error_Block * | eb | ||
) |
Create a GateMutex
gate.
prms | optional parameters |
eb | error block |
GateMutex | handle (NULL on failure) |
GateMutex_Handle GateMutex_construct | ( | GateMutex_Struct * | obj, |
const GateMutex_Params * | prms | ||
) |
Construct a GateMutex
gate.
GateMutex_construct is equivalent to GateMutex_create except that the GateMutex_Struct is pre-allocated.
obj | pointer to a GateMutex object |
prms | optional parameters |
GateMutex | handle (NULL on failure) |
void GateMutex_delete | ( | GateMutex_Handle * | gate | ) |
Delete a GateMutex
gate.
Note that GateMutex_delete takes a pointer to a GateMutex_Handle which enables GateMutex_delete to set the GateMutex handle to NULL.
gate | pointer to a GateMutex handle |
void GateMutex_destruct | ( | GateMutex_Struct * | obj | ) |
Destruct a GateMutex
gate.
obj | pointer to a GateMutex objects |
void GateMutex_Params_init | ( | GateMutex_Params * | prms | ) |
Initialize the GateMutex_Params structure with default values.
GateMutex_Params_init initializes the GateMutex_Params structure with default values. GateMutex_Params_init should always be called before setting individual parameter fields. This allows new fields to be added in the future with compatible defaults – existing source code does not need to change when new fields are added.
prms | pointer to uninitialized params structure |
intptr_t GateMutex_enter | ( | GateMutex_Handle | gate | ) |
enter the GateMutex gate
GateMutex_enter enters the GateMutex gate and returns a key for use by GateMutex_enter. GateMutex_enter calls can be nested and the key is used to unlock the gate on the final call to GateMutex_leave.
gate | GateMutex handle |
opaque | key to be passed to GateMutex_leave() |
void GateMutex_leave | ( | GateMutex_Handle | gate, |
intptr_t | key | ||
) |
leave the GateMutex gate
GateMutex_leave exits the GateMutex gate if key matches the outermost call to GateMutex_enter. If GateMutex_enter calls are nested, the key will keep the nested calls from leaving the gate.
gate | GateMutex handle |
key | opaque key to unlock the gate |
GateMutex_Handle GateMutex_Object_first | ( | void | ) |
return handle of the first GateMutex on GateMutex list
Return the handle of the first GateMutex on the create/construct list. NULL if no GateMutex instances have been created or constructed.
GateMutex | handle |
GateMutex_Handle GateMutex_Object_next | ( | GateMutex_Handle | gate | ) |
return handle of the next GateMutex on GateMutex list
Return the handle of the next GateMutex on the create/construct list. NULL if no more GateMutexs are on the list.
gate | GateMutex handle |
GateMutex | handle |