
for(;;)
{
  task1();
  task2();
  task3();
  task4();
}

void task1(void)
{
  //this is a simple task, just do it when needed
  if (!T2active) return;
  ....
}

void task2(void)
{
  // this task process a zero terminated character string 
  // when available and is 'sliced' in order not to
  // hog the processor
  switch (T2state)
    case 0:
    // nothing to do
    if (*cptr !=0)
    {
      T2state = 2;
    }
    break
    
    case 2:
    // process ONE character
    ....
    cptr++
    if (*cptr ==0)
    {
      T2state = 0;
    }
}
