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 #200 background imageLoading...
Page #200 background image
Queues
5-18
Example 5.18. Using QUE to Send Messages (continued)
/* ======== main ======== */
Void main()
{
/*
* Writer must be called before reader to ensure that the
* queue is non-empty for the reader.
*/
writer();
reader();
}
/* ======== reader ======== */
Void reader()
{
Msg msg;
Int i;
for (i=0; i < NUMMSGS; i++) {
/* The queue should never be empty */
if (QUE_empty(&queue)) {
SYS_abort("queue error\n");
}
/* dequeue message */
msg = QUE_get(&queue);
/* print value */
LOG_printf(&trace, "read '%c'.", msg->val);
/* free msg */
MEM_free(0, msg, sizeof(MsgObj));
}
}
/* ======== writer ======== */
Void writer()
{
Msg msg;
Int i;
for (i=0; i < NUMMSGS; i++) {
/* allocate msg */
msg = MEM_alloc(0, sizeof(MsgObj), 0);
if (msg == MEM_ILLEGAL) {
SYS_abort("Memory allocation failed!\n");
}
/* fill in value */
msg->val = i + 'a';
LOG_printf(&trace, "writing '%c' ...", msg->val);
/* enqueue message */
QUE_put(&queue, msg);
}
}

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