Using Semaphores

A semaphore is a ThreadX component used to coordinate access to shared resources or for mutual exclusion.

What are Semaphores typically used for?

Counting semaphores are typically used for mutual exclusion. However, counting semaphores can also be used as a method for event notification.
ThreadX places no constraints on how counting semaphores are used.

How do I create a Semaphore for a Synergy program?

You can create a semaphore either directly using the service tx_semaphore_create or by adding a new semaphore object to a thread in the Threads tab of the synergy configuration.

How can a Semaphore be used for event notification?

A notification callback function can be registered to be called every time the specified semaphore is put with the tx_semaphore_put_notify. This mechanism can be used to act immediately upon the availability of a resource and avoid polling.

What Semaphore functions are available?

ThreadX provides the following services (functions) for semaphores:

tx_semaphore_create

tx_semaphore_delete

tx_semaphore_get

tx_semaphore_put

tx_semaphore_put_notify

tx_semaphore_info_get

tx_semaphore_performance_info_get

tx_semaphore_performance_system_info_get

tx_semaphore_prioritize

For more information on these services consult the ThreadX documentation.

Where can I find some examples of Semaphore use in Synergy designs?

The audio playback example application uses semaphores and queues for inter-thread communications. You can find it by searching for "Synergy Audio Playback" in the search bar on the Renesas web site.

Where can I find more information?

You can find more information on the ThreadX user manual, available here: