WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
RW Semaphore
RW Semaphore 的协作图:

宏定义

#define LOS_ERRNO_RWSEM_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x00)
 
#define LOS_ERRNO_RWSEM_PTR_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x01)
 
#define LOS_ERRNO_RWSEM_ALL_BUSY   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x02)
 
#define LOS_ERRNO_RWSEM_PEND_INTERR   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x03)
 
#define LOS_ERRNO_RWSEM_PEND_IN_LOCK   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x04)
 
#define LOS_ERRNO_RWSEM_TIMEOUT   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x05)
 
#define LOS_ERRNO_RWSEM_PENDED   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x06)
 
#define LOS_ERRNO_RWSEM_INVALID_STATUS   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x07)
 
#define LOS_ERRNO_RWSEM_UNAVAILABLE   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x08)
 

函数

UINT32 LOS_RwsemCreate (UINT32 *semHandle)
 Create a RW semaphore.
 
UINT32 LOS_RwsemDelete (UINT32 semHandle)
 Delete a RW semaphore.
 
UINT32 LOS_RwsemPendRead (UINT32 semHandle, UINT32 timeout)
 Request a RW semaphore.
 
UINT32 LOS_RwsemPostRead (UINT32 semHandle)
 Release a RW semaphore.
 
UINT32 LOS_RwsemPendWrite (UINT32 semHandle, UINT32 timeout)
 Request a RW semaphore.
 
UINT32 LOS_RwsemPostWrite (UINT32 semHandle)
 Release a RW semaphore.
 
UINT32 LOS_RwsemDowngradeWrite (UINT32 semHandle)
 Release a RW semaphore.
 

详细描述

宏定义说明

◆ LOS_ERRNO_RWSEM_ALL_BUSY

#define LOS_ERRNO_RWSEM_ALL_BUSY   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x02)

RW Semaphore error code: No RW semaphore control structure is available.

Value: 0x02002202.

Solution: Perform corresponding operations based on the requirements in the code context.

◆ LOS_ERRNO_RWSEM_INVALID

#define LOS_ERRNO_RWSEM_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x00)

RW Semaphore error code: Invalid parameter.

Value: 0x02002200.

Solution: Change the passed-in invalid parameter value to a valid value.

◆ LOS_ERRNO_RWSEM_INVALID_STATUS

#define LOS_ERRNO_RWSEM_INVALID_STATUS   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x07)

RW Semaphore error code: Invalid status.

Value: 0x02002207.

Solution: Use the pend and post APIs in pairs.

◆ LOS_ERRNO_RWSEM_PEND_IN_LOCK

#define LOS_ERRNO_RWSEM_PEND_IN_LOCK   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x04)

RW Semaphore error code: The task is unable to request a semaphore because task scheduling is locked.

Value: 0x02002204.

Solution: Do not call the API when task scheduling is locked.

◆ LOS_ERRNO_RWSEM_PEND_INTERR

#define LOS_ERRNO_RWSEM_PEND_INTERR   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x03)

RW Semaphore error code: The API is called during an interrupt, which is forbidden.

Value: 0x02002203.

Solution: Do not call the API during an interrupt.

◆ LOS_ERRNO_RWSEM_PENDED

#define LOS_ERRNO_RWSEM_PENDED   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x06)

RW Semaphore error code: The waiting queue for the RW semaphore is not empty.

Value: 0x02002206.

Solution: Delete the RW semaphore after awaking all tasks that are waiting on the semaphore.

◆ LOS_ERRNO_RWSEM_PTR_NULL

#define LOS_ERRNO_RWSEM_PTR_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x01)

RW Semaphore error code: Null pointer.

Value: 0x02002201.

Solution: Change the passed-in null pointer to a valid non-null pointer.

◆ LOS_ERRNO_RWSEM_TIMEOUT

#define LOS_ERRNO_RWSEM_TIMEOUT   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x05)

RW Semaphore error code: The request for a RW semaphore times out.

Value: 0x02002205.

Solution: Change the passed-in parameter value to the value within the valid range.

◆ LOS_ERRNO_RWSEM_UNAVAILABLE

#define LOS_ERRNO_RWSEM_UNAVAILABLE   LOS_ERRNO_OS_ERROR(LOS_MOD_RWSEM, 0x08)

RW Semaphore error code: The RW semaphore is not immediately available.

Value: 0x02002208.

Solution: Obtain the RW semaphore only when the semaphore is available.

函数说明

◆ LOS_RwsemCreate()

UINT32 LOS_RwsemCreate ( UINT32 semHandle)
extern

Create a RW semaphore.

Description:
This API is used to create a RW semaphore control structure and return the ID of this semaphore control structure.
注意
None.
参数
semHandle[OUT] ID of the RW semaphore control structure that is initialized.
返回值
LOS_ERRNO_RWSEM_PTR_NULLThe passed-in semHandle value is NULL.
LOS_ERRNO_RWSEM_ALL_BUSYNo RW semaphore control structure is available.
LOS_OKThe RW semaphore is successfully created.
Dependency:
los_rwsem.h: the header file that contains the API declaration.
参见
LOS_RwsemDelete

◆ LOS_RwsemDelete()

UINT32 LOS_RwsemDelete ( UINT32  semHandle)
extern

Delete a RW semaphore.

Description:
This API is used to delete a RW semaphore control structure that has an ID specified by semHandle.
注意
The specified rwsem id must be created first before deleting it.
参数
semHandle[IN] ID of the RW semaphore control structure to be deleted. The ID of the RW semaphore control structure is obtained from semaphore creation.
返回值
LOS_ERRNO_RWSEM_INVALIDThe passed-in RW semHandle value is invalid.
LOS_ERRNO_RWSEM_PENDEDThe waiting queue for the RW semaphore is not empty.
LOS_OKThe RW semaphore control structure is successfully deleted.
Dependency:
los_rwsem.h: the header file that contains the API declaration.
参见
LOS_RwsemCreate

◆ LOS_RwsemDowngradeWrite()

UINT32 LOS_RwsemDowngradeWrite ( UINT32  semHandle)
extern

Release a RW semaphore.

Description:
This API is used to downgrade the write semaphore to the read semaphore.
注意
The specified rwsem id must be created first.
参数
semHandle[IN] ID of the RW semaphore control structure to be downgraded. The ID of the RW semaphore control structure is obtained from semaphore creation.
返回值
LOS_ERRNO_RWSEM_INVALIDThe passed-in RW semHandle value is invalid.
LOS_ERRNO_RWSEM_INVALID_STATUSInvalid status.
LOS_OKThe RW semaphore is successfully released.
Dependency:
los_rwsem.h: the header file that contains the API declaration.
参见
LOS_RwsemPendWrite | LOS_RwsemCreate

◆ LOS_RwsemPendRead()

UINT32 LOS_RwsemPendRead ( UINT32  semHandle,
UINT32  timeout 
)
extern

Request a RW semaphore.

Description:
This API is used to request a RW semaphore based on the semaphore control structure ID specified by semHandle and the parameter that specifies the timeout period.
注意
Do not pend rwsem during an interrupt. Do not pend rwsem in a system task, such as idle or swtmr task. The specified rwsem id must be created first. Do not recommend to use this API in software timer callback.
参数
semHandle[IN] ID of the RW semaphore control structure to be requested. The ID of the RW semaphore control structure is obtained from semaphore creation.
timeout[IN] Timeout interval for waiting on the RW semaphore. The value range is [0, 0xFFFFFFFF]. If the value is set to 0, the RW semaphore is not waited on. If the value is set to 0xFFFFFFFF, the RW semaphore is waited on forever(unit: Tick).
返回值
LOS_ERRNO_RWSEM_INVALIDThe passed-in semHandle value is invalid.
LOS_ERRNO_RWSEM_PEND_INTERRThe API is called during an interrupt, which is forbidden.
LOS_ERRNO_RWSEM_PEND_IN_LOCKThe task is unable to request a RW semaphore because task scheduling is locked.
LOS_ERRNO_RWSEM_TIMEOUTThe request for the RW semaphore times out.
LOS_OKThe RW semaphore request succeeds.
Dependency:
los_rwsem.h: the header file that contains the API declaration.
参见
LOS_RwsemPostRead | LOS_RwsemCreate

◆ LOS_RwsemPendWrite()

UINT32 LOS_RwsemPendWrite ( UINT32  semHandle,
UINT32  timeout 
)
extern

Request a RW semaphore.

Description:
This API is used to request a RW semaphore based on the semaphore control structure ID specified by semHandle and the parameter that specifies the timeout period.
注意
Do not pend rwsem during an interrupt. Do not pend rwsem in a system task, such as idle or swtmr task. The specified rwsem id must be created first. Do not recommend to use this API in software timer callback.
参数
semHandle[IN] ID of the RW semaphore control structure to be requested. The ID of the RW semaphore control structure is obtained from semaphore creation.
timeout[IN] Timeout interval for waiting on the RW semaphore. The value range is [0, 0xFFFFFFFF]. If the value is set to 0, the RW semaphore is not waited on. If the value is set to 0xFFFFFFFF, the RWsemaphore is waited on forever(unit: Tick).
返回值
LOS_ERRNO_RWSEM_INVALIDThe passed-in semHandle value is invalid.
LOS_ERRNO_RWSEM_PEND_INTERRThe API is called during an interrupt, which is forbidden.
LOS_ERRNO_RWSEM_PEND_IN_LOCKThe task is unable to request a RW semaphore because task scheduling is locked.
LOS_ERRNO_RWSEM_TIMEOUTThe request for the semaphore times out.
LOS_OKThe RW semaphore request succeeds.
Dependency:
los_rwsem.h: the header file that contains the API declaration.
参见
LOS_RwsemPostWrite | LOS_RwsemCreate

◆ LOS_RwsemPostRead()

UINT32 LOS_RwsemPostRead ( UINT32  semHandle)
extern

Release a RW semaphore.

Description:
This API is used to release a RW semaphore that has a semaphore control structure ID specified by semHandle.
注意
The specified rwsem id must be created first.
参数
semHandle[IN] ID of the RW semaphore control structure to be released. The ID of the RW semaphore control structure is obtained from semaphore creation.
返回值
LOS_ERRNO_RWSEM_INVALIDThe passed-in semHandle value is invalid.
LOS_ERRNO_RWSEM_INVALID_STATUSInvalid status.
LOS_OKThe RW semaphore is successfully released.
Dependency:
los_rwsem.h: the header file that contains the API declaration.
参见
LOS_RwsemPendRead | LOS_RwsemCreate

◆ LOS_RwsemPostWrite()

UINT32 LOS_RwsemPostWrite ( UINT32  semHandle)
extern

Release a RW semaphore.

Description:
This API is used to release a RW semaphore that has a RW semaphore control structure ID specified by semHandle.
注意
The specified rwsem id must be created first.
参数
semHandle[IN] ID of the RW semaphore control structure to be released. The ID of the RW semaphore control structure is obtained from semaphore creation.
返回值
LOS_ERRNO_RWSEM_INVALIDThe passed-in semHandle value is invalid.
LOS_ERRNO_RWSEM_INVALID_STATUSInvalid status.
LOS_OKThe RW semaphore is successfully released.
Dependency:
los_rwsem.h: the header file that contains the API declaration.
参见
LOS_RwsemPendWrite | LOS_RwsemCreate