OSQPendAbort
Description
Aborts and readies any tasks currently waiting on a message queue. This function should be used to fault-abort the wait on the message queue, rather than to signal the message queue via OSQPost()
.
Files
os.h/os_q.c
Prototype
OS_OBJ_QTY OSQPendAbort (OS_Q *p_q, OS_OPT opt, OS_ERR *p_err)
Arguments
p_q
is a pointer to the queue for which pend(s) need to be aborted.
opt
determines the type of abort to be performed.
OS_OPT_PEND_ABORT_1
Aborts the pend of only the highest-priority task waiting on the message queue.
OS_OPT_PEND_ABORT_ALL
Aborts the pend of all tasks waiting on the message queue.
OS_OPT_POST_NO_SCHED
specifies that the scheduler should not be called, even if the pend of a higher-priority task has been aborted. Scheduling will need to occur from another function.
You would use this option if the task calling OSQPendAbort()
is doing additional pend aborts, rescheduling is not performed until completion, and multiple pend aborts are to take effect simultaneously.
p_err
is a pointer to a variable that holds an error code:
OS_ERR_NONE
at least one task waiting on the message queue was readied and informed of the aborted wait. Check the return value for the number of tasks whose wait on the message queue was aborted.
OS_ERR_OBJ_PTR_NULL
If OS_CFG_ARG_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if p_q
is a NULL
pointer.
OS_ERR_OBJ_TYPE
If OS_CFG_OBJ_TYPE_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if p_q
is not pointing to a message queue.
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_ISR
If OS_CFG_CALLED_FROM_ISR_CHK_EN
set to DEF_ENABLED
in os_cfg.h
: if called from an ISR
OS_ERR_PEND_ABORT_NONE
If no task was pending on the message queue
Returned Value
OSQPendAbort()
returns the number of tasks made ready-to-run by this function. Zero indicates that no tasks were pending on the message queue, or an error.
Required Configuration
OS_CFG_Q_EN
and OS_CFG_Q_PEND_ABORT_EN
must be enabled in os_cfg.h
. Refer to µC-OS-III Configuration Manual.
Callers
Application.
Notes/Warnings
- Queues must be created before they are used.
Example Usage
OS_Q CommQ; void CommTask(void *p_arg) { OS_ERR err; OS_OBJ_QTY nbr_tasks; (void)&p_arg; while (DEF_ON) { : : nbr_tasks = OSQPendAbort(&CommQ, OS_OPT_PEND_ABORT_ALL, &err); /* Check "err" */ : : } }