Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A message queue is a kernel object allocated by the application. In fact, you can allocate any number of message queues. The only limit is the amount of RAM available.

There are a number of operations that the user can perform on message queues, summarized in Figure 15-1. However, an ISR can only call OSQPost(). A message queue must be created before sending messages through it.

Message queues are drawn as a first-in, first-out pipe (FIFO). However, with µC/OS-III, it is possible to post messages in last-in, first-out order (LIFO). The LIFO mechanism is useful when a task or an ISR must send an “urgent” message to a task. In this case, the message bypasses all other messages already in the message queue. The size of the message queue is configurable at run-time.

The small hourglass close to the receiving task (F15-1) indicates that the task has an option to specify a timeout. This timeout indicates that the task is willing to wait for a message to be sent to the message queue within a certain amount of time. If the message is not sent within that time, µC/OS-III resumes the task and returns an error code indicating that the task was made ready-to-run because of a timeout, and not because the message was received. It is possible to specify an infinite timeout and indicate that the task is willing to wait forever for the message to arrive.

...

Include Page
css.Migrating from uC-OS-II to uC-OS-III.css
css.Migrating from uC-OS-II to uC-OS-III.css
Include Page
css.webworks.css
css.webworks.css

Anchor
1080089
1080089
Message Queues

Anchor
1080090
1080090
Table C-12 shows the difference in API for message-queue management.

Anchor
1181585
1181585
 

HTML Table
summary
classPlain_Table
Table Row (tr)
Table Cell (td)

Anchor
1091598
1091598
µC/OS-II (os_q.c)

Table Cell (td)

Anchor
1091600
1091600
µC/OS-III (os_q.c)

Table Cell (td)

Anchor
1091602
1091602
Note

Table Row (tr)
Table Cell (td)
rowspan4

Anchor
1091604
1091604
void *

Anchor
1091605
1091605
OSQAccept(

Anchor
1091606
1091606
OS_EVENT *pevent,

Anchor
1091607
1091607
INT8U *perr);

Table Cell (td)
rowspan4

Anchor
1091609
1091609
 

Table Cell (td)
rowspan4

Anchor
1091611
1091611
(1)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)
Table Cell (td)
rowspan4

Anchor
1091631
1091631
OS_EVENT *

Anchor
1091632
1091632
OSQCreate(

Anchor
1091633
1091633
void **start,

Anchor
1091634
1091634
INT16U size);

Table Cell (td)
rowspan4

Anchor
1091636
1091636
void

Anchor
1091637
1091637
OSQCreate(

Anchor
1091638
1091638
OS_Q *p_q,

Anchor
1091639
1091639
CPU_CHAR *p_name,

Anchor
1091640
1091640
OS_MSG_QTY max_qty,

Anchor
1091641
1091641
OS_ERR *p_err);

Table Cell (td)
rowspan4

Anchor
1091643
1091643
(2)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)
Table Cell (td)
rowspan5

Anchor
1091663
1091663
OS_EVENT *

Anchor
1091664
1091664
OSQDel(

Anchor
1091665
1091665
OS_EVENT *pevent,

Anchor
1091666
1091666
INT8U opt,

Anchor
1091667
1091667
INT8U *perr);

Table Cell (td)
rowspan5

Anchor
1091669
1091669
OS_OBJ_QTY,

Anchor
1091670
1091670
OSQDel(

Anchor
1091671
1091671
OS_Q *p_q,

Anchor
1091672
1091672
OS_OPT opt,

Anchor
1091673
1091673
OS_ERR *p_err);

Table Cell (td)
rowspan5

Anchor
1091675
1091675
 

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)
Table Cell (td)
rowspan7

Anchor
1091701
1091701
INT8U

Anchor
1091702
1091702
OSQFlush(

Anchor
1091703
1091703
OS_EVENT *pevent);

Table Cell (td)
rowspan7

Anchor
1091705
1091705
OS_MSG_QTY

Anchor
1091706
1091706
OSQFlush(

Anchor
1091707
1091707
OS_Q *p_q,

Anchor
1091708
1091708
OS_ERR *p_err);

Table Cell (td)
rowspan7

Anchor
1091710
1091710
 

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)
Table Cell (td)
rowspan8

Anchor
1091748
1091748
void *

Anchor
1091749
1091749
OSQPend(

Anchor
1091750
1091750
OS_EVENT *pevent,

Anchor
1091751
1091751
INT32U timeout,

Anchor
1091752
1091752
INT8U *perr);

Table Cell (td)
rowspan8

Anchor
1091754
1091754
void *

Anchor
1091755
1091755
OSQPend(

Anchor
1091756
1091756
OS_Q *p_q,

Anchor
1091757
1091757
OS_MSG_SIZE *p_msg_size,

Anchor
1091758
1091758
OS_TICK timeout,

Anchor
1091759
1091759
OS_OPT opt,

Anchor
1091760
1091760
CPU_TS *p_ts,

Anchor
1091761
1091761
OS_ERR *p_err);

Table Cell (td)
rowspan8

Anchor
1091763
1091763
(3)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)
Table Cell (td)
rowspan12

Anchor
1091807
1091807
INT8U

Anchor
1091808
1091808
OSQPendAbort(

Anchor
1091809
1091809
OS_EVENT *pevent,

Anchor
1091810
1091810
INT8U opt,

Anchor
1091811
1091811
INT8U *perr);

Table Cell (td)
rowspan12

Anchor
1091813
1091813
OS_OBJ_QTY

Anchor
1091814
1091814
OSQPendAbort(

Anchor
1091815
1091815
OS_Q *p_q,

Anchor
1091816
1091816
OS_OPT opt,

Anchor
1091817
1091817
OS_ERR *p_err);

Table Cell (td)
rowspan12

Anchor
1091819
1091819
 

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)
Table Cell (td)
rowspan4

Anchor
1091887
1091887
INT8U

Anchor
1091888
1091888
OSQPost(

Anchor
1091889
1091889
OS_EVENT *pevent,

Anchor
1091890
1091890
void *pmsg);

Table Cell (td)
rowspan4

Anchor
1091892
1091892
void

Anchor
1091893
1091893
OSQPost(

Anchor
1091894
1091894
OS_Q *p_q,

Anchor
1091895
1091895
void *p_void,

Anchor
1091896
1091896
OS_MSG_SIZE msg_size,

Anchor
1091897
1091897
OS_OPT opt,

Anchor
1091898
1091898
OS_ERR *p_err);

Table Cell (td)
rowspan4

Anchor
1091900
1091900
(4)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)
Table Cell (td)
rowspan5

Anchor
1091920
1091920
INT8U

Anchor
1091926
1091926
OSQPostFront(

Anchor
1091932
1091932
OS_EVENT *pevent,

Anchor
1091938
1091938
void *pmsg);

Table Cell (td)
rowspan5

Anchor
1091946
1091946
 

Table Cell (td)
rowspan5

Anchor
1091948
1091948
 

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)
Table Cell (td)
rowspan5

Anchor
1091950
1091950
INT8U

Anchor
1091956
1091956
OSQPostOpt(

Anchor
1091962
1091962
OS_EVENT *pevent,

Anchor
1091968
1091968
void *pmsg,

Anchor
1091974
1091974
INT8U opt);

Table Cell (td)
rowspan5

Anchor
1091952
1091952
 

Table Cell (td)
rowspan5

Anchor
1091978
1091978
(4)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Table Row (tr)
Table Cell (td)
rowspan4

Anchor
1091980
1091980
INT8U

Anchor
1091986
1091986
OSQQuery(

Anchor
1091992
1091992
OS_EVENT *pevent,

Anchor
1091998
1091998
OS_Q_DATA *p_q_data);

Table Cell (td)
rowspan4

Anchor
1091982
1091982
 

Table Cell (td)
rowspan4

Anchor
1092002
1092002
(5)

Table Row (tr)

Table Row (tr)

Table Row (tr)

Anchor
1080165
1080165
 

    1. Anchor
      1159659
      1159659
      Message Queue Management API
      1. Anchor
        1080166
        1080166
        In µC/OS-III, there is no “accept” API as this feature is built into the OSQPend() by specifying the OS_OPT_PEND_NON_BLOCKING option.
      2. Anchor
        1080167
        1080167
        In µC/OS-II, OSQCreate() returns the address of an OS_EVENT, which is used as the “handle” to the message queue. In µC/OS-III, the application must allocate storage for an OS_Q object, which serves the same purpose as the OS_EVENT. The benefit in µC/OS-III is that it is not necessary to predetermine at compile time, the number of message queues.
      3. Anchor
        1080168
        1080168
        µC/OS-III returns additional information when a message queue is posted. Specifically, the sender includes the size of the message and takes a snapshot of the current timestamp and stores it in the message. The receiver of the message therefore knows when the message was posted.
      4. Anchor
        1080169
        1080169
        In µC/OS-III, OSQPost() offers a number of options that replaces the three post functions provided in µC/OS-II.
      5. Anchor
        1080170
        1080170
        µC/OS-III does not provide query services as they were rarely used.