Files | |
file | mars_task_semaphore_types.h |
MARS Task Semaphore Types. | |
file | mars_task_semaphore.h |
[host] MARS Task Semaphore API | |
file | mars_task_semaphore.h |
[MPU] MARS Task Semaphore API | |
Data Structures | |
struct | mars_task_semaphore |
MARS task semaphore structure. More... | |
Defines | |
#define | MARS_TASK_SEMAPHORE_SIZE 128 |
Size of task semaphore structure. | |
#define | MARS_TASK_SEMAPHORE_ALIGN 128 |
Alignment of task semaphore structure. | |
#define | MARS_TASK_SEMAPHORE_ALIGN_MASK 0x7f |
Alignment mask of task semaphore structure. | |
#define | MARS_TASK_SEMAPHORE_WAIT_MAX 55 |
Maximum task accesses allowed for single semaphore. | |
Functions | |
int | mars_task_semaphore_initialize (struct mars_context *mars, struct mars_task_semaphore *semaphore, int32_t count) |
[host] Initializes a task semaphore. | |
int | mars_task_semaphore_initialize (uint64_t semaphore_ea, int32_t count) |
[MPU] Initializes a task semaphore. | |
int | mars_task_semaphore_acquire (uint64_t semaphore_ea) |
[MPU] Acquires a task semaphore. (Blocking) | |
int | mars_task_semaphore_release (uint64_t semaphore_ea) |
[MPU] Releases a task semaphore. | |
Variables | |
mars_task_semaphore | MARS_TASK_SEMAPHORE_ALIGN |
MARS task semaphore structure. |
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_initialize | ( | struct mars_context * | mars, | |
struct mars_task_semaphore * | semaphore, | |||
int32_t | count | |||
) |
[host] Initializes a task semaphore.
[in] | mars | - pointer to initialized MARS context |
[out] | semaphore | - pointer to semaphore instance to initialize |
[in] | count | - initial number of task accesses allowed |
int mars_task_semaphore_initialize | ( | uint64_t | semaphore_ea, | |
int32_t | count | |||
) |
[MPU] Initializes a task semaphore.
[out] | semaphore_ea | - ea of semaphore instance to initialize |
[in] | count | - initial number of task accesses allowed |
int mars_task_semaphore_acquire | ( | uint64_t | semaphore_ea | ) |
[MPU] Acquires a task semaphore. (Blocking)
[in] | semaphore_ea | - ea of initialized semaphore instance |
int mars_task_semaphore_release | ( | uint64_t | semaphore_ea | ) |
[MPU] Releases a task semaphore.
[in] | semaphore_ea | - ea of initialized semaphore instance |
MARS task semaphore structure.
An instance of this structure must be created when using any of the MARS semaphore API.
If allocating a memory area for this structure, make sure to allocate a memory area that is aligned to MARS_TASK_SEMAPHORE_ALIGN bytes and of size MARS_TASK_SEMAPHORE_SIZE bytes.