...
The sender and receiver are unaware of this data structure since everything is hidden through the APIs provided by µC/OS-III.
Panel |
---|
borderWidth | 0 |
---|
title | OS_MSG Structure |
---|
|
Image Added |
µC/OS-III maintains a pool of free OS_MSGs
. The total number of available messages in the pool is determined by the value of OS_CFG_MSG_POOL_SIZE
found in os_cfg_app.h
. When µC/OS-III is initialized, OS_MSGs
are linked in a single linked list as shown in the the figure below. Notice that the free list is maintained by a data structure of type OS_MSG_POOL
, which contains four (4) fields: .NextPtr
, which points to the free list; .NbrFree
, which contains the number of free OS_MSGs
in the pool, .NbrUsed
, which contains the number of OS_MSGs
allocated to the application and, .NbrUsedMax
which detects the maximum number of messages allocated to the application.
Panel |
---|
borderWidth | 0 |
---|
title | Pool of Free OS_MSGs |
---|
|
Image Added |
Messages are queued using a data structure of type OS_MSG_Q
, as shown in the figure below.
Panel |
---|
borderWidth | 0 |
---|
title | OS_MSG_Q Structure |
---|
|
Image Added |
.InPtr
This field contains a pointer to where the next OS_MSG
will be inserted in the queue. In fact, the OS_MSG
will be inserted “after” the OS_MSG
pointed to.
...
The figure below shows an example of an OS_MSG_Q
when four OS_MSGs
are inserted.
Panel |
---|
borderWidth | 0 |
---|
title | OS_MSG_Q with four OS_MSGs |
---|
|
Image Added |
OS_MSG_Qs
are used inside two additional data structures: OS_Q
and OS_TCB
. Recall that an OS_Q
is declared when creating a message queue object. An OS_TCB
is a task control block and, as previously mentioned, each OS_TCB
can have its own message queue when the configuration constant OS_CFG_TASK_Q_EN
is set to DEF_ENABLED
in os_cfg.h
. The figure below shows the contents of an OS_Q
and partial contents of an OS_TCB
containing an OS_MSG_Q
. The OS_MSG_Q
data structure is shown as an “exploded view” to emphasize the structure within the structure.
Panel |
---|
borderWidth | 0 |
---|
title | OS_Q and OS_TCB each contain an OS_MSG_Q |
---|
|
Image Added |