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