OS_SEM_CTR OSTaskSemPend (OS_TICK timeout,
OS_OPT opt,
CPU_TS *p_ts,
OS_ERR *p_err)
File | Called from | Code enabled by |
---|---|---|
| Task only | Always enabled |
...
Description
OSTaskSemPend()
allows a task to wait for a signal to be sent by another task or ISR without going through an intermediate object such as a semaphore. If the task was previously signaled when when OSTaskSemPend()
is is called then, the caller resumes.
If no signal was received by the task and and OS_OPT_PEND_BLOCKING
is is specified for the the opt
argument argument, OSTaskSemPend()
suspends suspends the current task until either a signal is received, or a user-specified timeout expires. A pended task suspended with with OSTaskSuspend()
can can receive signals. However, the task remains suspended until it is resumed by calling calling OSTaskResume()
.
If no signals were sent to the task and and OS_OPT_PEND_NON_BLOCKING
was was specified for the the opt
argument argument, OSTaskSemPend()
returns returns to the caller with an appropriate error code and returns a signal count of of 0
.
Files
os.h/os_task.c
Prototype
Arguments
timeout
allows the task to resume execution if a signal is not received from a task or an ISR within the specified number of clock ticks. A timeout value of 0
indicates that the task wants to wait forever for a signal. The timeout value is not synchronized with the clock tick. The timeout count starts decrementing on the next clock tick, which could potentially occur immediately.
...
OS_ERR_NONE
If a signal is received.
OS_ERR_OPT_INVALID
If OS_CFG_ARG_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if a valid option is not specified.
OS_ERR_OS_NOT_RUNNING
If OS_CFG_INVALID_OS_CALLS_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if µC/OS-III is not running yet.
OS_ERR_PEND_ABORT
If the pend was aborted because another task called OSTaskSemPendAbort()
.
...
If OS_CFG_CALLED_FROM_ISR_CHK_EN
set to 1
in DEF_ENABLED
in os_cfg.h
: if calling this function from an ISR.
...
If calling this function when the scheduler is locked and the user wanted the task to block.
OS_ERR_STATUS_INVALID
If the pend status has an invalid value.
OS_ERR_TIMEOUT
If a signal is not received within the specified timeout.
...
The current value of the signal counter after it has been decremented. In other words, the number of signals still remaining in the signal counter.
Required Configuration
Always enabled.
Callers
Application.
Notes/Warnings
- Do not call
OSTaskSemPend()
from an ISR.