Zephyr Project API 3.7.0
A Scalable Open Source RTOS
|
Macros | |
#define | SYS_SEM_DEFINE(_name, _initial_count, _count_limit) |
Statically define and initialize a sys_sem. | |
Functions | |
int | sys_sem_init (struct sys_sem *sem, unsigned int initial_count, unsigned int limit) |
Initialize a semaphore. | |
int | sys_sem_give (struct sys_sem *sem) |
Give a semaphore. | |
int | sys_sem_take (struct sys_sem *sem, k_timeout_t timeout) |
Take a sys_sem. | |
unsigned int | sys_sem_count_get (struct sys_sem *sem) |
Get sys_sem's value. | |
#define SYS_SEM_DEFINE | ( | _name, | |
_initial_count, | |||
_count_limit | |||
) |
#include <include/zephyr/sys/sem.h>
Statically define and initialize a sys_sem.
The semaphore can be accessed outside the module where it is defined using:
Route this to memory domains using K_APP_DMEM().
_name | Name of the semaphore. |
_initial_count | Initial semaphore count. |
_count_limit | Maximum permitted semaphore count. |
#include <include/zephyr/sys/sem.h>
Get sys_sem's value.
This routine returns the current value of sem.
sem | Address of the sys_sem. |
int sys_sem_give | ( | struct sys_sem * | sem | ) |
#include <include/zephyr/sys/sem.h>
Give a semaphore.
This routine gives sem, unless the semaphore is already at its maximum permitted count.
sem | Address of the semaphore. |
0 | Semaphore given. |
-EINVAL | Parameter address not recognized. |
-EACCES | Caller does not have enough access. |
-EAGAIN | Count reached Maximum permitted count and try again. |
#include <include/zephyr/sys/sem.h>
Initialize a semaphore.
This routine initializes a semaphore instance, prior to its first use.
sem | Address of the semaphore. |
initial_count | Initial semaphore count. |
limit | Maximum permitted semaphore count. |
0 | Initial success. |
-EINVAL | Bad parameters, the value of limit should be located in (0, INT_MAX] and initial_count shouldn't be greater than limit. |
int sys_sem_take | ( | struct sys_sem * | sem, |
k_timeout_t | timeout | ||
) |
#include <include/zephyr/sys/sem.h>
Take a sys_sem.
This routine takes sem.
sem | Address of the sys_sem. |
timeout | Waiting period to take the sys_sem, or one of the special values K_NO_WAIT and K_FOREVER. |
0 | sys_sem taken. |
-EINVAL | Parameter address not recognized. |
-ETIMEDOUT | Waiting period timed out. |
-EACCES | Caller does not have enough access. |