A sync object is an object used to synchronize between two threads, or between a thread and an interrupt handler. One thread is waiting on the object and the other thread or interrupt handler sends a signal, which then releases the waiting thread. The signal can be sent from an interrupt context. This object is generally implemented by binary semaphore.
The type of the sync object is defined by the host application as needed, by defining the _SlSyncObj_t function as a typedef or a macro.
#define _SlSyncObj_t HANDLE
The following functions should also be implemented:
- sl_SyncObjCreate – Creates a sync object. The function receives a pointer to a memory control block for the object, which is later passed to the other functions of the sync object.
- sl_SyncObjDelete – Destroys a sync object. If one of the threads already waits on the sync object while this function is called, the driver expects that the waiting thread will exit with an error when this function is called.
- sl_SyncObjSignal – Generates a synchronization signal to the sync object from a thread context, which should release the other thread context that is waiting on this sync object.
- sl_SyncObjSignalFromIRQ – The same as sl_SyncObjSignal, but called from an interrupt handler routine. In most operating systems, there is no difference between these functions, but in some operating systems there is a special function for this operation.
- sl_SyncObjWait – Waits for a synchronization signal of a specific sync object. The calling thread is blocked on this function until the signal is generated or time-out value elapsed. If the function is called after the signal is already generated, the waiting thread should be released immediately.