Asynchronous Notifications
Zephyr APIs often include async functions where an
operation is initiated and the application needs to be informed when it
completes, and whether it succeeded. Using k_poll()
is
often a good method, but some application architectures may be more
suited to a callback notification, and operations like enabling clocks
and power rails may need to be invoked before kernel functions are
available so a busy-wait for completion may be needed.
This API is intended to be embedded within specific subsystems such as On-Off Manager and other APIs that support async transactions. The subsystem wrappers are responsible for extracting operation-specific data from requests that include a notification element, and for invoking callbacks with the parameters required by the API.
A limitation is that this API is not suitable for System Calls because:
sys_notify
is not a kernel object;copying the notification content from userspace will break use of
CONTAINER_OF
in the implementing function;neither the spin-wait nor callback notification methods can be accepted from userspace callers.
Where a notification is required for an asynchronous operation invoked
from a user mode thread the subsystem or driver should provide a syscall
API that uses k_poll_signal
for notification.