SHDesigns: Embedded Systems Design, Consulting and Developer Resources Page hits:


The CoExec is a simple task switcher for use with the Softools Rabbit C compiler.

This exec is not designed to compete with TurboTask and uCOS. If you need preemptive-tasking, semaphores, events, message queues etc; use the TurboTask exec. This library is free and comes with little tech support. Hopefully users will support each other via the message boards,

A discussion topic has been set up on the SHDesigns rabbit board:

CoExec has been used by SHDesigns for porting programs written for the Z-World DC compiler to Softools. It does not emulate the DC costate and cofunc model. It does provide similar functionality. It has worked reliably in several projects.

CoExec provides real tasks instead of costates. This eliminates much of the task "churning" of the DC model. Each task has its own stack. This isolates stack problems between tasks. Delays, i.e. waitMS(), are implemented in the exec so the task does not have to repeatedly call the same function just to add a delay.

A sample application is included. It demonstrates most of the features of the exec and shows how the tasks operate.

The full source and sample projects are now available

The Documentation can be viewed here:

The lib, include file, documentation and sample project can be downloaded here:

Update 07-03-2008: Event change

  1. set_event does not call task_switch(). This allows it to called from an interrupt.
  2. set_event() flags the first task waiting on the event as the next task to run.
  3. Some cleanups for readability.

Updated 12-30-2005: Minor change.

The task list, tasks[] needed one extra empty entry or the lib would try to run an invalid task. This has been fixed

Updated 8-8-2004. Latest version adds new features:

  1. Supports far stacks, this saves root memory space and allows each task to have large stacks.
  2. Allows main stack to be split
  3. Faster task switching <14us on a 22mHz R3000
  4. Preemptive support now more robust.
  5. Task switch counters removed.
  6. Function task_swap removed. Now task_switch can be called directly from a timer function
    restart_task now needs param to pass to task (param no longer stored in globals)