XCSB Multitasking

Multitasking on the 14 bit core series PICs is a challenge. The hardware stack is not accessable to normal logic so it is impossible to determin what data is on the hardware stack or to manipulate it in any way.

This makes pre-emptive task schedualing impossible.

XCSB provides co-operative multitasking which by-passes the hardware stack.

Currently the maximum number of tasks supported is limited to 4.

The names of the tasks are currently restricted to

When started, an XCSB program consists of just the single task called main.

This task can start, stop or suspend itself or any other task.

Beware, because of the nature of multitasking, breaking a problem down into seperate distinct tasks can greatly simplify the solution but also greatly increase the RAM and code space required. Normally when XCSB generates machine code and allocates RAM, it does so in such a manor that allows a program to re-use temporary space such as function parameters and local variables. However when a function is used by two seperate tasks, the use of the function has to be carefully analysed. If the function or any other function that it uses performs task specific operations then the function could be interrupted by another task. This meens that such functions need their own task safe context. This is achived by producing a copy of the function together with its own context for each task that needs to use it. A copy of the code is necessary because the code is directly linked to its own RAM. Using pointers to select a context would actually incure significant overheads which would only be worth while in the most trivial cases.

The following task primitives are available