Texas Instruments TMS320 User Manual page 151

Dsp/bios v5.40
Hide thumbs Also See for TMS320:
Table of Contents

Advertisement

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);
}
}
Thread Scheduling
Tasks
4-47

Advertisement

Table of Contents
loading

Table of Contents