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 #167 background imageLoading...
Page #167 background image
Semaphores
Thread Scheduling 4-63
Example 4.11. SEM Example Using Three Writer Tasks (continued)
Note:
Non-pointer type function arguments to LOG_printf need explicit type
casting to (Arg) as shown in the following code example:
LOG_printf(&trace, "Task %d Done", (Arg)id);
/*
* ======== writer ========
*/
Void writer(Int id)
{
Msg msg;
Int i;
for (i = 0; i < NUMMSGS; i++) {
/*
* Get msg from the free queue. Since reader is higher
* priority and only blocks on sem, this queue is
* never empty.
*/
if (QUE_empty(&freeQueue)) {
SYS_abort(“Empty free queue!\n”);
}
msg = QUE_get(&freeQueue);
/* fill in value */
msg->id = id;
msg->val = (i & 0xf) + ‘a’;
LOG_printf(&trace, “(%d) writing ‘%c’ ...”, id, msg->val);
/* enqueue message */
QUE_put(&msgQueue, msg);
/* post semaphore */
SEM_post(&sem);
/* 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