信号量

类型定义

typedef aos_hdl_t aos_sem_t
 

函数

aos_status_t aos_sem_create (aos_sem_t *sem, uint32_t count, uint32_t options)
 
void aos_sem_free (aos_sem_t *sem)
 
aos_status_t aos_sem_wait (aos_sem_t *sem, uint32_t timeout)
 
void aos_sem_signal (aos_sem_t *sem)
 
void aos_sem_signal_all (aos_sem_t *sem)
 
aos_status_t aos_sem_new (aos_sem_t *sem, uint32_t count)
 
bool aos_sem_is_valid (aos_sem_t *sem)
 

详细描述

提供AliOS Things系统内核信号量功能的基础API.

类型定义说明

◆ aos_sem_t

AOS信号量对象句柄类型

在文件 kernel.h118 行定义.

函数说明

◆ aos_sem_create()

aos_status_t aos_sem_create ( aos_sem_t sem,
uint32_t  count,
uint32_t  options 
)

Alloc a semaphore.

参数
[out]sempointer of semaphore object, semaphore object must be alloced, hdl pointer in aos_sem_t will refer a kernel obj internally.
[in]countinitial semaphore counter.
[in]optionsreserved.
返回
0:success.

◆ aos_sem_free()

void aos_sem_free ( aos_sem_t sem)

Destroy a semaphore.

参数
[in]sempointer of semaphore object, mem refered by hdl pointer in aos_sem_t will be freed internally.

◆ aos_sem_is_valid()

bool aos_sem_is_valid ( aos_sem_t sem)

This function will check if semaphore is valid. Deprecated, not Recommended.

参数
[in]sempointer to the sem.
返回
false: invalid, true: valid.

◆ aos_sem_new()

aos_status_t aos_sem_new ( aos_sem_t sem,
uint32_t  count 
)

Alloc a semaphore. Deprecated, not Recommended.

参数
[out]sempointer of semaphore object, semaphore object must be alloced, hdl pointer in aos_sem_t will refer a kernel obj internally.
[in]countinitial semaphore counter.
返回
0:success.

◆ aos_sem_signal()

void aos_sem_signal ( aos_sem_t sem)

Release a semaphore.

参数
[in]semsemaphore object, it contains kernel obj pointer which aos_sem_new alloced.

◆ aos_sem_signal_all()

void aos_sem_signal_all ( aos_sem_t sem)

Release all semaphore.

参数
[in]semsemaphore object, it contains kernel obj pointer which aos_sem_new alloced.

◆ aos_sem_wait()

aos_status_t aos_sem_wait ( aos_sem_t sem,
uint32_t  timeout 
)

Acquire a semaphore.

参数
[in]semsemaphore object, it contains kernel obj pointer which aos_sem_new alloced.
[in]timeoutwaiting until timeout in milliseconds.
返回
0: success.