1.. _module-pw_sync_embos: 2 3============= 4pw_sync_embos 5============= 6This is a set of backends for pw_sync based on embOS v4. 7 8-------------------------------- 9Critical Section Lock Primitives 10-------------------------------- 11 12Mutex & TimedMutex 13================== 14The embOS v4 backend for the Mutex and TimedMutex use ``OS_RSEMA`` as the 15underlying type. It is created using ``OS_CreateRSema`` as part of the 16constructors and cleaned up using ``OS_DeleteRSema`` in the destructors. 17 18InterruptSpinLock 19================= 20The embOS v4 backend for InterruptSpinLock is backed by a ``bool`` which permits 21these objects to detect accidental recursive locking. 22 23This object uses ``OS_IncDI`` and ``OS_DecRI`` to mask interrupts which enables 24the critical section. In addition, ``OS_SuspendAllTasks`` and 25``OS_ResumeAllSuspendedTasks`` are used to to prevent accidental thread context 26switches while the InterruptSpinLock is locked. 27 28-------------------- 29Signaling Primitives 30-------------------- 31 32ThreadNotification & TimedThreadNotification 33============================================ 34Prefer using the binary semaphore backends for ThreadNotifications, as the 35native embOS v4 implementation of its semaphores (``OS_CSEMA``) is very 36efficient: 37 38- ``pw_sync:binary_semaphore_thread_notification_backend`` 39- ``pw_sync:binary_semaphore_timed_thread_notification_backend`` 40 41BinarySemaphore & CountingSemaphore 42=================================== 43The embOS v4 backends for the BinarySemaphore and CountingSemaphore use 44``OS_CSEMA`` as the underlying type. It is created using ``OS_CreateCSema`` as 45part of the constructor and cleaned up using ``OS_DeleteCSema`` in the 46destructor. 47