39int sem_init(sem_t *sem,
int shared,
unsigned int value)
45 if ((sem == NULL) || (value > OS_SEM_COUNT_MAX)) {
55 sem->sem = GET_SEM(semHandle);
64 if ((sem == NULL) || (sem->sem == NULL)) {
81 if ((sem == NULL) || (sem->sem == NULL)) {
86 ret =
LOS_SemPend(sem->sem->semID, LOS_WAIT_FOREVER);
99 if ((sem == NULL) || (sem->sem == NULL)) {
108 if ((errno != EINVAL) || (ret == LOS_ERRNO_SEM_UNAVAILABLE)) {
120 if ((sem == NULL) || (sem->sem == NULL)) {
143 if ((sem == NULL) || (sem->sem == NULL)) {
160 if ((sem == NULL) || (currVal == NULL)) {
164 val = sem->sem->semCount;
173sem_t *
sem_open(
const char *name,
int openFlag, ...)
LITE_OS_SEC_TEXT_INIT UINT32 LOS_SemCreate(UINT16 count, UINT32 *semHandle)
对外接口 创建信号量
LITE_OS_SEC_TEXT UINT32 LOS_SemPost(UINT32 semHandle)
对外接口 释放指定的信号量
LITE_OS_SEC_TEXT UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout)
对外接口 申请指定的信号量,并设置超时时间
LITE_OS_SEC_TEXT_INIT UINT32 LOS_SemDelete(UINT32 semHandle)
对外接口 删除指定的信号量,参数就是 semID
int map_errno(UINT32 err)
int sem_post(sem_t *sem)
增加信号量计数
int sem_timedwait(sem_t *sem, const struct timespec *timeout)
设置获取信号量时间,时间到了不管是否获取也返回.
int sem_getvalue(sem_t *sem, int *currVal)
int sem_init(sem_t *sem, int shared, unsigned int value)
sem_t * sem_open(const char *name, int openFlag,...)
int sem_trywait(sem_t *sem)
尝试获取信号量
int sem_close(sem_t *sem)
int sem_destroy(sem_t *sem)
销毁指定的信号量
int sem_unlink(const char *name)
int sem_wait(sem_t *sem)
获取信号量
STATIC INLINE BOOL ValidTimeSpec(const struct timespec *tp)
STATIC INLINE UINT32 OsTimeSpec2Tick(const struct timespec *tp)