Semaphores

For general purpose resource management and synchronisation, a semaphore primitive is provided. poco provides both binary and counting semaphores for use within coroutines and ISRs.

Sempahores are a generalisation of mutexes and can be used for synchronisation between coroutines and ISRs, or for managing access to a shared resource with a specific number of instances.

For synchronisation between coroutines only, consider using Mutexes instead.

This functionality is available from the specific header <poco/semaphore.h>.

Creating a Semaphore

Semaphores can either be created statically or dynamically. This API provides the *_create and *_create_static variants for both types of semaphores.

Acquiring and Releasing

Sempahores can be acquired and released using the *_acquire and *_release functions. The exact function depends on the execution context of the caller.

Warning

Failure to release the semaphore may cause a deadlock, where all other coroutines will wait their defined timeout.