circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

December 1998, Issue 101

A Minimalist Multitasking Executive


by Richard Man & Christina Willrich
Start Task Function Scheduling and Timeslice Task Context Task Control Block Global Variables Memory Management API Assembly Functions Give it a Try Enhancements References, Sources & PDF

GIVE IT A TRY

The simple example shown in Listing 4 creates two tasks that print out 0s and 1s. In addition to traditional programming uses, µexec can be used to implement subsumption architecture, which is a powerful programming paradigm particularly suitable for programming autonomous robots.

#include "uexec.h"

unsigned char task_zero_stack[UEXC_MIN_STACK_SIZE];
unsigned char task_one_stack[UEXC_MIN_STACK_SIZE];

void Zero(void)
{
  while (1)
  putchar('0');
}

void One(void)
{
  while (1)
  putchar('1');
}

void main(void)
{
  UEXC_CreateTask(Zero, task_zero_stack, sizeof task_zero_stack), 0);
  UEXC_CreateTask(One, task_one_stack, sizeof (task_one_stack), 0);
  UEXC_StartScheduler();
}

Listing 4—This trivial program tests µexec’s basic functionality. Two tasks are created, and each one prints out a different character on the output.

If you’re interested, we recommend checking out Mobile Robots, Inspiration to Implementation [1] for more detailed information on subsumption programming.