Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

OS_MSG_QTY  OSTaskQFlush (OS_TCB    *p_tcb,
                          OS_ERR  *p_err)

File

Called from

Code enabled by

os_task.c

Task only

OS_CFG_TASK_Q_EN

OSTaskQFlush() empties the contents of the task message queue and eliminates all messages sent to the queue. OS_MSGs from the queue are simply returned to the free pool of OS_MSGs.

Arguments

p_tcb

is a pointer to the TCB of the task that contains the queue to flush. Specifying a NULL pointer tells OSTaskQFlush() to flush the queue of the calling task’s built-in message queue.

p_err

is a pointer to a variable that will contain an error code returned by this function.

OS_ERR_NONE

if the message queue is flushed.

OS_ERR_FLUSH_ISR

if OS_CFG_CALLED_FROM_ISR_CHK_EN set to 1 in os_cfg.h: if calling this function from an ISR

Returned Value

The number of OS_MSG entries freed from the message queue. Note that the OS_MSG entries are returned to the free pool of OS_MSGs.

Notes/Warnings

  • Use this function with great care. When flushing a queue, you lose the references to what the queue entries are pointing to, potentially causing 'memory leaks'. The data that the user is pointing to that is referenced by the queue entries should, most likely, be de-allocated (i.e., freed).
  • Example

    or, to flush a queue that contains entries, instead you can use OSTaskQPend() and specify the OS_OPT_PEND_NON_BLOCKING option.

    • No labels