Mailboxes
Thread Scheduling
4-65
4.8 Mailboxes
The MBX module provides a set of functions to manage mailboxes. MBX
mailboxes can be used to pass messages from one task to another on the
same processor. An intertask synchronization enforced by a fixed length
shared mailbox can be used to ensure that the flow of incoming messages
does not exceed the ability of the system to process those messages. The
examples given in this section illustrate just such a scheme.
The mailboxes managed by the MBX module are separate from the mailbox
structure contained within a SWI object.
MBX_create and MBX_delete are used to create and delete mailboxes,
respectively. You can also create mailbox objects statically. See Section 2.4,
Creating DSP/BIOS Objects Dynamically
, page 2-16, for a discussion of the
benefits of creating objects statically.
You specify the mailbox length and message size when you create a mailbox
as shown in Example 4-12.
Example 4-12.
Creating a Mailbox
MBX_pend is used to read a message from a mailbox as shown in Example
4-13. If no message is available (that is, the mailbox is empty), MBX_pend
blocks. In this case, the timeout parameter allows the task to wait until a
timeout, to wait indefinitely, or to not wait at all.
Example 4-13.
Reading a Message from a Mailbox
Conversely, MBX_post is used to post a message to the mailbox as shown in
Example 4-14. If no message slots are available (that is, the mailbox is full),
MBX_post blocks. In this case, the timeout parameter allows the task to wait
until a timeout, to wait indefinitely, or to not wait at all.
MBX_Handle MBX_create(msgsize, mbxlength, attrs)
Uns msgsize;
Uns mbxlength;
MBX_Attrs *attrs;
Void MBX_delete(mbx)
MBX_Handle mbx;
Bool MBX_pend(mbx, msg, timeout)
MBX_Handle mbx;
Void *msg;
Uns timeout; /* return after this many */
/* system clock ticks */
Summary of Contents for TMS320 Series
Page 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Page 16: ...xvi ...
Page 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Page 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Page 202: ...5 20 ...
Page 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Page 288: ...Index 10 Index ...