EasyManuals Logo

Texas Instruments TMS320 User Manual

Texas Instruments TMS320
288 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #172 background imageLoading...
Page #172 background image
Mailboxes
4-68
Example 4.15. MBX Example With Two Types of Tasks (continued)
After the program runs, review the trace log contents. The results should be
similar to that shown in Figure 4-15.
/*
* ======== reader ========
*/
Void reader(Void)
{
MsgObj msg;
Int i;
for (i=0; ;i++) {
/* wait for mailbox to be posted by writer() */
if (MBX_pend(&mbx, &msg, TIMEOUT) == 0) {
LOG_printf(&trace, "timeout expired for MBX_pend()");
break;
}
/* print value */
LOG_printf(&trace, "read ’%c’ from (%d).", msg.val, msg.id);
}
LOG_printf(&trace, "reader done.");
}
/*
* ======== writer ========
*/
Void writer(Int id)
{
MsgObj msg;
Int i;
for (i=0; i < NUMMSGS; i++) {
/* fill in value */
msg.id = id;
msg.val = i % NUMMSGS + (Int)(‘a’);
LOG_printf(&trace, "(%d) writing ‘%c’ ...", id,
(Int)msg.val);
/* enqueue message */
MBX_post(&mbx, &msg, TIMEOUT);
/* what happens if you call TSK_yield() here? */
/* TSK_yield(); */
}
LOG_printf(&trace, "writer (%d) done.", id);
}

Table of Contents

Other manuals for Texas Instruments TMS320

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TMS320 and is the answer not in the manual?

Texas Instruments TMS320 Specifications

General IconGeneral
BrandTexas Instruments
ModelTMS320
CategoryComputer Hardware
LanguageEnglish

Related product manuals