[riot-notifications] [RIOT-OS/RIOT] core: Added thread_signal & thread_await_signal (#11006)

Marian Buschsieweke notifications at github.com
Tue Feb 12 16:54:29 CET 2019


### Contribution description

`thread_sleep()` and `thread_wakeup()` provide simple means to signal an event to a thread. However, the calls need to be synchronized: The waiting thread has to call `thread_sleep()` before `thread_wakeup()` is called.

This commit adds `thread_await_signal()` and `thread_signal()` which do not need to be synchronized: If `thread_signal()` is called between to calls to `thread_await_signal()`, the second call to `thread_await_signal()` will return immediately. If `thread_await_signal()` is called before the matching call to `thread_signal()`, they will behave like `thread_wakeup()` and `thread_sleep()`.

### Testing procedure

As `thread_sleep()` and `thread_wakeup()` are changed to internally use `thread_await_signal()` and `thread_signal()`, testing if they still work should be done. `thread_await_signal()` and `thread_signal()` could be tested with https://github.com/RIOT-OS/RIOT/pull/10340, which I will update to use this PR after my next appointment. I could also provide a minimum example application using both APIs, if needed be.

### Issues/PRs references

Used in PR https://github.com/RIOT-OS/RIOT/pull/10340 to make `netdev_driver_t::send()` blocking while still handling ISRs in a way that does not block the CPU for a couple of milliseconds. PR https://github.com/RIOT-OS/RIOT/pull/8304 be rewritten to use this more lightweight API instead of `thread_flags`. (To avoid confusion: This API is unable to replace `thread_flags` and does not want to do this. But in the use cases both could be used, this API is more lightweight.) Maybe also `at86rf2xx` implementation to make `netdev_driver_t::send()` blocking while waiting TX to complete could use this API and an interrupt instead of busy waiting for TX to complete.
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/11006

-- Commit Summary --

  * core: Added thread_signal & thread_await_signal

-- File Changes --

    M core/include/thread.h (80)
    M core/thread.c (31)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11006.patch
https://github.com/RIOT-OS/RIOT/pull/11006.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11006
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190212/056b37cb/attachment.html>


More information about the notifications mailing list