Task Synchronization with SynthOS

One of the key features for a real time OS is the capability to synchronize and schedule tasks in the system. Traditional systems would use semaphores or mutexes for synchronizing task access to resources and message queues for synchronizing between tasks. SynthOS uses the primitive SynthOS_wait(condition), where condition can be an expression or a task name. The running task will halt and wait for the condition to be valid or for the specified task to block or terminate. There is another way to synchronize tasks by using the SynthOS_sleep() primitive and a simple while or if statement. Using this method, the task will be scheduled based on the system architecture, repeatedly checking the condition. It is a simple implementation but not efficient in terms of processor utilization and power consumption compared to using SynthOS_wait(), but we can utilize the implicit SynthOS_sleep() at the end of every task, which is more efficient in terms of code size.

In a SynthOS generated ASOS system, a function that is defined as a Loop Task is run continuously by the scheduler; once the function terminates, the task control block (TCB) is not released. The system will put the TCB at the end of the task queue (for round-robin scheduling) or reevaluate the scheduling according to the task priority (for priority scheduling), effectively introducing an implicit SynthOS_sleep() primitive at the end of the task. Both of the methods for synchronizing tasks will enable other tasks to run before the scheduler gets back to checking the condition and continuing with the execution of the task. Option 1, without using the SynthOS primitives will save memory and simplify the code compared to option 2, using the SynthOS_wait() primitive. It also makes it easier to check multiple conditions using an if() or a case() statement. The benefit of using the SynthOS_wait() primitive is that the system can be put into sleep mode and woken up from an interrupt. Figure 1 shows the two options the user has.

Figure 1

Figure 1 Implementing task synchronization with SynthOS

These two options show the flexibility the developer has when using SynthOS to develop a real-time embedded system, by using the basic five primitives and the different configurations as defined in the system configuration file. These options are also available in many of the other RTOSes on the market today, but they are implemented by using a large number, sometimes hundreds, of unique APIs. SynthOS achieves the same capabilities by using only five primitives and a configuration file, but the system analysis process will automatically generate the appropriate code to support the required functionality.

Jacob Harel
VP of Product Management
Zeidman Technologies

Leave a Reply

Your email address will not be published. Required fields are marked *