Part 1
요약·해설
Subsystem wrapper 책임, sys_notify가 syscall에 부적합한 세 이유와 user mode의 k_poll_signal 대안을 설명합니다.
k_poll
Spin-wait
k_poll_signal syscall
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
9EC288D002C6EB8E33C2DD87AA277C69B8722852630CE562F662566C772EA715
.. _async_notification:
Asynchronous Notifications
##########################
Zephyr APIs often include :ref:`api_term_async` functions where an
operation is initiated and the application needs to be informed when it
completes, and whether it succeeded. Using :c:func:`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
:ref:`resource_mgmt_onoff` 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 :ref:`syscalls`
because:
* :c:struct:`sys_notify` is not a kernel object;
* copying the notification content from userspace will break use of
:c:macro:`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 :c:struct:`k_poll_signal` for notification.
API Reference
*************
.. doxygengroup:: sys_notify_apis
Part 3
한국어 전문 번역
Zephyr API에는 operation을 시작한 뒤 완료 여부와 성공 여부를 application에 알려야 하는 asynchronous function이 자주 있습니다. k_poll()이 적절한 경우가 많지만 application architecture에 따라 callback notification이 더 잘 맞을 수 있습니다. Clock이나 power rail enable처럼 kernel function을 쓸 수 있기 전에 호출해야 하는 operation은 완료까지 busy-wait가 필요할 수도 있습니다.
이 API는 resource_mgmt_onoff처럼 async transaction을 지원하는 특정 subsystem 안에 embed하도록 설계됐습니다. Subsystem wrapper는 notification element가 포함된 request에서 operation-specific data를 꺼내고, 해당 API가 요구하는 parameter로 callback을 호출할 책임이 있습니다.
이 API는 syscall에는 적합하지 않습니다.
sys_notify는 kernel object가 아닙니다.- Notification content를 userspace에서 copy하면 implementation의
CONTAINER_OF사용이 깨집니다. - Spin-wait와 callback notification method 모두 userspace caller에서 허용할 수 없습니다.
User mode thread가 시작한 asynchronous operation에 notification이 필요하면 subsystem이나 driver가 k_poll_signal을 사용하는 syscall API를 제공해야 합니다.
API Reference
Asynchronous notification helper API는 sys_notify_apis Doxygen group에 있습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.