Example [Niche]Tasks

from netmain.c

extern task * to_task2;
TK_OBJECT(to_task2);
TK_ENTRY(tk_task2);
long     task2_wakes  =  0;

...

struct inet_taskinfo nettasks[]  =  {
   ...
   {
      &to_task2,
      "task2",
      tk_task2,
      NET_PRIORITY - 1,
      IO_STACK_SIZE,
   }
};

int
netmain(void)
{
   ...
   e = TK_NEWTASK(&nettasks[i]);
   ...
}

The file task2.c

#include "ipport.h"

extern long task2_wakes; /* count wakeups */


/* FUNCTION: TK_ENTRY()
 *
 * Task2 - Every now and then, wake up and print '!' on stdout
 * 
 * RETURNS: never
 */

TK_ENTRY(tk_task2)
{
   for (;;)
   {
      TK_SLEEP( (TPS*2)-1 ); 
      dprintf("!");
      task2_wakes++; /* count wakeups */

   }
   TK_RETURN_OK();
}