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-47
Example 4.7. Time-Slice Scheduling (continued)
/* ======== main ======== */
Void main()
{
LOG_printf(&trace, "Slice example started!");
counts_per_us = CLK_countspms() / 1000;
}
/* ======== task ======== */
Void task(Arg id_arg)
{
Int id = ArgToInt(id_arg);
LgUns time;
LgUns prevtime;
/*
* The while loop below simulates the work load of
* the time sharing tasks
*/
while (1) {
time = CLK_gethtime() / counts_per_us;
/* print time only every 200 usec */
if (time >= prevtime + 200) {
prevtime = time;
LOG_printf(&trace, "Task %d: time is(us) Ox%x",
id, (Int)time);
}
/* check for rollover */
if (prevtime > time) {
prevtime = time;
}
/*
* pass through idle loop to pump data to the Real-Time
* Analysis tools
*/
TSK_disable();
IDL_run();
TSK_enable();
}
}
/* ======== hi_pri_task ======== */
Void hi_pri_task(Arg id_arg)
{
Int id = ArgToInt(id_arg);
while (1) {
LOG_printf(&trace, "Task %d here", id);
SEM_pend(&sem, SYS_FOREVER);
}
}

Table of Contents

Other manuals for Texas Instruments TMS320

Related product manuals