Tasks, Execution Contexts, and threads


Can anyone provide a concrete definition of the relationship between the OpenAT tasks and execution contexts, and underlying threads of execution? I have been trying to determine exactly how the operating system performs threading, in particular with respect to application code and multiple tasks.

I would like to know, for instance, if each task defined in the application runs in a separate thread, or if all tasks are run in a single thread. It appears that the latter is the case, but it is really difficult to tell experimentally.

If it is the case that each task is essentially a thread, how do I as the application developer control synchronization? Do I need to implement my own locking structure? The Semaphore service provided by OpenAT only works across execution contexts, and is therefore really limited (since it will not work for inter-task control). In particular, I would very much like to implement a wait-notify style coordination system similar to those in boost and Java for driving events through a system.



OpenAT uses what they call “Pre-emptive multitasking”. The only thing “multi” about it is that you can have multiple tasks. These tasks DO NOT run concurrently. The task with the highest priority (set in the adl_InitTasks table) runs until it has finished execution and returns to idle. Then the next highest priority task runs until it is idle, etc.

If a lower priority task is running, and an event occurs that triggers a higher priority task (for example, a timer expires), the higher priority task will “pre-empt” the lower priority task (i.e. suspend it), and will run until it returns to idle. The lower priority task will then continue from where it left off. There can be multiple levels of pre-emption, and multiple tasks can be suspended while a high priority task runs.

With regards to “synchronizing” tasks, the event service can be used to suspend a high level task until a low level task has completed some code and raises an event to un-suspend the high level task.

A good way of passing data between tasks to ensure your functions run with the correct priority is to use the message service (read the stuff in the ADL user guide about how functions called from a certain task will run with that priority, while certain callback handlers run in certain priority tasks)

This system makes it easy to ensure that the most important code runs when it needs to, while less important code is run in the “background”. It takes a little while to get your head around, but its actually pretty simple :slight_smile: Good luck!


Thanks for the explanation. That really does clear things up.