Files | |
file | task_semaphore_types.h |
[host/MPU] MARS Task Semaphore Types | |
file | task_semaphore.h |
[host] MARS Task Semaphore API | |
file | task_semaphore.h |
[MPU] MARS Task Semaphore API | |
Defines | |
#define | MARS_TASK_SEMAPHORE_WAIT_MAX 55 |
Maximum task accesses allowed for single semaphore. | |
Functions | |
int | mars_task_semaphore_create (struct mars_context *mars, uint64_t *semaphore_ea, int32_t count) |
[host] Creates a task semaphore. | |
int | mars_task_semaphore_destroy (uint64_t semaphore_ea) |
[host] Destroys a task semaphore. | |
int | mars_task_semaphore_acquire (uint64_t semaphore_ea) |
[MPU] Acquires a task semaphore. (Task Switch Call) | |
int | mars_task_semaphore_release (uint64_t semaphore_ea) |
[MPU] Releases a task semaphore. |
Whenever a task wants to access some semaphore protected shared resource, it must first request to acquire the semaphore access (P operation) of the semaphore. When done accessing the shared resource it must then release access (V operation) of the semaphore. If attempting to request a a semaphore and other tasks have already requested the total number of allowed accesses, the task will transition to the waiting state until some other tasks release the semaphore and access is obtained.
int mars_task_semaphore_create | ( | struct mars_context * | mars, | |
uint64_t * | semaphore_ea, | |||
int32_t | count | |||
) |
[host] Creates a task semaphore.
This function will allocate an instance of the task semaphore. The semaphore allows for tasks to wait until a semaphore can be obtained. The semaphore should be used in pairs with calls to acquire and release.
Key Parameters:
count
[in] | mars | - pointer to MARS context |
[out] | semaphore_ea | - ea of semaphore instance |
[in] | count | - initial number of task accesses allowed |
int mars_task_semaphore_destroy | ( | uint64_t | semaphore_ea | ) |
[host] Destroys a task semaphore.
This function will free any resources allocated during creation of the task semaphore.
[in] | semaphore_ea | - ea of semaphore instance |
int mars_task_semaphore_acquire | ( | uint64_t | semaphore_ea | ) |
[MPU] Acquires a task semaphore. (Task Switch Call)
[in] | semaphore_ea | - ea of initialized semaphore instance |
int mars_task_semaphore_release | ( | uint64_t | semaphore_ea | ) |
[MPU] Releases a task semaphore.
This function will release a previously acquired semaphore. If their are other tasks currently waiting to acquire a semaphore, calling this function will resume a waiting task to allow it to acquire the semaphore.
[in] | semaphore_ea | - ea of initialized semaphore instance |