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 8 Next »

void  OSTaskQPost (OS_TCB      *p_tcb,
                   void        *p_void,
                   OS_MSG_SIZE  msg_size,
                   OS_OPT       opt,
                   OS_ERR      *p_err)

File

Called from

Code enabled by

os_q.c

Task or ISR

OS_CFG_TASK_Q_EN and OS_CFG_MSG_EN

OSTaskQPost() sends a message to a task through its local message queue. A message is a pointer-sized variable, and its use is application specific. If the task’s message queue is full, an error code is returned to the caller. In this case, OSTaskQPost() immediately returns to its caller, and the message is not placed in the message queue.

If the task receiving the message is waiting for a message to arrive, it will be made ready-to-run. If the receiving task has a higher priority than the task sending the message, the higher-priority task resumes, and the task sending the message is suspended; that is, a context switch occurs. A message can be posted as first-in first-out (FIFO), or last-in-first-out (LIFO), depending on the value specified in the opt argument. In either case, scheduling occurs unless opt is set to OS_OPT_POST_NO_SCHED.

Arguments

p_tcb

is a pointer to the TCB of the task. Note that it is possible to post a message to the calling task (i.e., self) by specifying a NULL pointer, or the address of its TCB.

p_void

is the actual message sent to the task. p_void is a pointer-sized variable and its meaning is application specific.

msg_size

specifies the size of the message posted (in number of bytes).

opt

determines the type of POST performed. Of course, it does not make sense to post LIFO and FIFO simultaneously, so these options are exclusive:

OS_OPT_POST_FIFO

POST message to task and place at the end of the queue if the task is not waiting for messages.

OS_OPT_POST_LIFO

POST message to task and place at the front of the queue if the task is not waiting for messages.

OS_OPT_POST_NO_SCHED

This option prevents calling the scheduler after the post and therefore the caller is resumed.

You should use this option if the task (or ISR) calling OSTaskQPost() will be doing additional posts, the user does not want to reschedule until all done, and multiple posts are to take effect simultaneously.

 

p_err

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

OS_ERR_NONE

If the call was successful and the message was posted to the task’s message queue.

OS_ERR_MSG_POOL_EMPTY

If running out of OS_MSG to hold the message being posted.

OS_ERR_Q_MAX

If the task’s message queue is full and cannot accept more messages.

Returned Value

None

Notes/Warnings

None

Example

  • No labels