zephyr::kio

Module sync

Source
Expand description

Synchronization mechanisms that work with async.

Notably, Zephyr’s k_mutex type isn’t supported as a type that can be waited for asynchronously.

The main problem with k_mutex (meaning crate::sync::Mutex) is that the lock operation can block, and since multiple tasks may be scheduled for the same work queue, the system can deadlock, as the scheduler may not run to allow the task that actually holds the mutex to run.

As an initial stopgap. We provide a Mutex type that is usable within an async context. We do not currently implement an associated Condvar.

Note that using Semaphores for locking means that this mechanism doesn’t handle priority inversion issues. Be careful with workers that run at different priorities.

Structs§

  • A mutual exclusion primitive useful for protecting shared data. Async version.
  • An RAII implementation of a held lock.