Thursday, June 29, 2006

Tiny Threads - Tiny Multitasking Threads for Microcontrollers

by: Regulus Berdin
Limitations:
  • Maximum 254 lines per thread.
  • Thread context switching will not work within a switch block.
Usage example:
     TT_DEF(1)
{
TT_BEGIN(1);
while (1)
{
...
TT_SWITCH(1);
...
...
TT_WAIT_UNTIL(1,keypress);
}
TT_END(1);
}

TT_DEF(LED_TASK)
{
TT_BEGIN(LED_TASK);
while (1)
{
LedOn();
delay=DELAY_1_SECOND;
TT_WAIT_UNTIL(LED_TASK,delay==0);
LedOff();
delay=DELAY_1_SECOND;
TT_WAIT_UNTIL(LED_TASK,delay==0);
}
TT_END(LED_TASK);
}

void main(void)
{
...
...
while(1)
{
TT_SCHED(1);
TT_SCHED(LED_TASK);
}
}


Visit Site

0 Comments:

Post a Comment

<< Home