WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
osal_semaphore

函数

int osal_sem_init (osal_semaphore *sem, int val)
 Create a semaphore.
 
int osal_sem_binary_sem_init (osal_semaphore *sem, int val)
 Create a binary semaphore.
 
int osal_sem_down (osal_semaphore *sem)
 Request a semaphore.
 
int osal_sem_down_timeout (osal_semaphore *sem, unsigned int timeout)
 Acquire the semaphore within a specified time that specifies the timeout period.
 
int osal_sem_down_interruptible (osal_semaphore *sem)
 acquire the semaphore unless interrupted.
 
int osal_sem_trydown (osal_semaphore *sem)
 try to acquire the semaphore, without waiting.
 
void osal_sem_up (osal_semaphore *sem)
 Release a semaphore.
 
void osal_sem_destroy (osal_semaphore *sem)
 Delete a semaphore.
 

详细描述

函数说明

◆ osal_sem_binary_sem_init()

int osal_sem_binary_sem_init ( osal_semaphore sem,
int  val 
)

Create a binary semaphore.

Description:
This API is used to create a binary semaphore control structure according to the initial number of available semaphores specified by count
参数
val[in] Initial number of available semaphores. The value range is [0, 1].
sem[out] Pointer of semaphore control structure that is initialized.
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
liteos freertos.

◆ osal_sem_destroy()

void osal_sem_destroy ( osal_semaphore sem)

Delete a semaphore.

Description:
This API is used to destroy semaphore and release space.
注意
The specified sem must be created first before deleting it.
参数
sem[in] The semaphore to destroyed.
Support System:
linux liteos freertos.

◆ osal_sem_down()

int osal_sem_down ( osal_semaphore sem)

Request a semaphore.

Description:
This API is used to attempt to obtain the semaphore. Acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is released.
注意
Do not pend sem during an interrupt. Do not pend sem in a system task, such as idle or swtmr task. The specified sem id must be created first. Do not recommend to use this API in software timer callback.
参数
sem[in] The semaphore to be acquired.
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
linux liteos freertos.

◆ osal_sem_down_interruptible()

int osal_sem_down_interruptible ( osal_semaphore sem)

acquire the semaphore unless interrupted.

Description:
Acquire the semaphore unless interrupted. Attempts to acquire the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep.
参数
sem[in] The semaphore to be acquired.
返回
If the sleep is interrupted by a signal, this function will return OSAL_EINTR. If the semaphore is successfully acquired, this function returns OSAL_SUCCESS, failed return OSAL_FAILURE
Support System:
linux liteos freertos.

◆ osal_sem_down_timeout()

int osal_sem_down_timeout ( osal_semaphore sem,
unsigned int  timeout 
)

Acquire the semaphore within a specified time that specifies the timeout period.

Description:
Acquire the semaphore within a specified time that specifies the timeout period.
注意
Do not pend sem during an interrupt. Do not pend sem in a system task, such as idle or swtmr task. The specified sem id must be created first. Do not recommend to use this API in software timer callback.
参数
sem[in] The semaphore to be acquired.
timeout[in] How long to wait before failing. (unit: ms)
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
liteos freertos.

◆ osal_sem_init()

int osal_sem_init ( osal_semaphore sem,
int  val 
)

Create a semaphore.

Description:
This API is used to create a semaphore control structure according to the initial number of available semaphores specified by count
参数
val[in] Initial number of available semaphores.
sem[out] Pointer of semaphore control structure that is initialized.
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
linux liteos freertos.

◆ osal_sem_trydown()

int osal_sem_trydown ( osal_semaphore sem)

try to acquire the semaphore, without waiting.

Description:
try to acquire the semaphore, without waiting.
注意
This return value is inverted from both spin_trylock and mutex_trylock! Be careful about this when converting code. Unlike mutex_trylock, this function can be used from interrupt context, and the semaphore can be released by any task or interrupt.
参数
sem[in] The semaphore to be acquired.
返回
If the semaphore cannot be obtained, the system returns 1 instead of sleeping. If the value 0 is returned, the semaphore is obtained.
Support System:
linux liteos freertos.

◆ osal_sem_up()

void osal_sem_up ( osal_semaphore sem)

Release a semaphore.

Description:
Release a semaphore.
注意
Unlike mutexes, osal_sem_up() may be called from any context and even by tasks which have never called osal_sem_down().
参数
sem[in] The semaphore to release.
Support System:
linux liteos freertos.