EasyManua.ls Logo

Texas Instruments TMS320

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
Loading...
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

Related product manuals