...
Files
os.h/os_sem.c
Prototype
Code Block |
---|
void OSSemSet (OS_SEM *p_sem,
OS_SEM_CTR cnt,
OS_ERR *p_err) |
Arguments
p_sem
is a pointer to the semaphore that is used as a signaling mechanism.
...
OS_ERR_NONE
If the count was changed or, not changed, because one or more tasks was waiting on the semaphore.
OS_ERR_OBJ_PTR_NULL
If OS_CFG_ARG_CHK_EN
is set to 1
in DEF_ENABLED
in os_cfg.h
: if p_sem
is a NULL
pointer.
...
If OS_CFG_OBJ_TYPE_CHK_EN
is set to 1
in DEF_ENABLED
in os_cfg.h
: if p_sem
is not pointing to a semaphore.
...
If OS_CFG_CALLED_FROM_ISR_CHK_EN
set to 1
in DEF_ENABLED
in os_cfg.h
: if this function was called from an ISR.
...
If tasks are waiting on the semaphore, the count is not changed.
Returned Value
None
Required Configuration
OS_CFG_SEM_EN
and OS_CFG_SEM_SET_EN
must be enabled in os_cfg.h
. Refer to uCµC-OS-III Configuration Manual.
Callers
Application.
Notes/Warnings
- Do not use this function if the semaphore is used to protect a shared resource.
Example Usage
Code Block | ||
---|---|---|
| ||
OS_SEM SwSem;
void Task (void *p_arg)
{
OS_ERR err;
(void)&p_arg;
while (DEF_ON) {
OSSemSet(&SwSem, /* Reset the semaphore count */
0,
&err);
/* Check "err" */
:
:
}
} |