Usage

Multitasking

  • Every task i defined in a C function.
int function(ARG arg0, ...)
{
  puts("Hello World !\n");

  return 0;
}
  • Everything is multitasked, to start the execution of a C function you have to spawn a task for it.
taskSpawn("helloWorld", priority, options, stack_size, function, args ...);
  • Tasks can be put to sleep for a certain amount of kernel ticks. (time units)
taskDelay(timeout);

Synchronization

  • Semaphores are used to synchronize access to shared resources among different tasks.
semTake(semId, timeout);
..
..
..
semGive(semId);
  • Events can be sent between different tasks.
TCB_ID pTcb = NULL;
int receiverTask(void)
{
  int returned_events;
  for (;;) {
    eventReceive(events, options, timeout, &returned_events);
    puts("Got event: ");
    puts(itoa(returned_events));
    puts("\n");
  }

  return 0;
}

int senderTask(void)
{
  for (;;) {
    eventSend((void *)pTcb, events);
    taskDelay(18);
  }

  return 0;
}

int main(void)
{
  pTcb = taskSpawn("receiver", priority, options, stack_size receiverTask, ...);
  taskSpawn("sender", priority, options, stack_size, senderTask, ...);

  return 0;
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License