Semaphore API
This API provides standard semaphore functionality, but with added diagnostic capabilities. These semaphores can only be shared by threads within the same process.
Semaphores can wait (decrease value by one) and post (increase value by one).
In Legato, semaphores are dynamically allocated objects.
Creating a Semaphore
le_sem_Create() creates a semaphore, returning a reference to it (of type le_sem_Ref_t).
All semaphores have names. This is required for diagnostic purposes. See Diagnostics below.
Using a Semaphore
Functions to increase and decrease semaphores are:
Function to get a semaphore's current value is:
Deleting a Semaphore
When you are finished with a semaphore, you must delete it by calling le_sem_Delete().
There must not be anything using the semaphore when it is deleted (i.e., no one can be waiting on it).
Diagnostics
The command-line inspect tool can be used to list the semaphores that currently exist inside a given process. The state of each semaphore can be seen, including a list of any threads that might be waiting for that semaphore.
Copyright (C) Sierra Wireless Inc.