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 #166 background imageLoading...
Page #166 background image
Semaphores
4-62
Example 4.11. SEM Example Using Three Writer Tasks (continued)
/*
* ======== main ========
*/
Void main()
{
Int i;
MsgObj *msg;
Uns mask;
mask = TRC_LOGTSK | TRC_LOGSWI | TRC_STSSWI | TRC_LOGCLK;
TRC_enable(TRC_GBLHOST | TRC_GBLTARG | mask);
msg = (MsgObj *)MEM_alloc(0, NUMMSGS * sizeof(MsgObj), 0);
if (msg == MEM_ILLEGAL) {
SYS_abort(“Memory allocation failed!\n”);
}
/* Put all messages on freequeue */
for (i = 0; i < NUMMSGS; msg++, i++) {
QUE_put(&freeQueue, msg);
}
}
/*
* ======== reader ========
*/
Void reader()
{
Msg msg;
Int i;
for (i = 0; i < NUMMSGS * NUMWRITERS; i++) {
/*
* Wait for semaphore to be posted by writer().
*/
SEM_pend(&sem, SYS_FOREVER);
/* dequeue message */
msg = QUE_get(&msgQueue);
/* print value */
LOG_printf(&trace, “read ‘%c’ from (%d).”, msg->val, msg-
>id);
/* free msg */
QUE_put(&freeQueue, msg);
}
LOG_printf(&trace, “reader done.”);
}

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