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 #149 background imageLoading...
Page #149 background image
Tasks
Thread Scheduling 4-45
Example 4-6. Creating a Task Object
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);
#define CONTEXTSIZE `size of additional context`
Void doCreate(task)
TSK_Handle task;
{
Ptr context;
context = MEM_alloc(0, CONTEXTSIZE, 0);
TSK_setenv(task, context); /* set task environment */
}
Void doDelete(task)
TSK_Handle task;
{
Ptr context;
context = TSK_getenv(task); /* get register buffer */
MEM_free(0, context, CONTEXTSIZE);
}
Void doSwitch(from, to)
TSK_Handle from;
TSK_Handle to;
{
Ptr context;
static Int first = TRUE;
if (first) {
first = FALSE;
return;
}
context = TSK_getenv(from); /* get register buffer */
*context = `hardware registers`; /* save registers */
context = TSK_getenv(to); /* get register buffer /
`hardware registers` = *context; /* restore registers */
}
Void doExit(Void)
{
TSK_Handle usrHandle;
/* get task handle, if needed */
usrHandle = TSK_self();
`perform user-defined exit steps`
}

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