[riot-notifications] [RIOT-OS/RIOT] core: API and datatype change for handling thread states (#10989)

Marian Buschsieweke notifications at github.com
Mon Feb 11 16:12:57 CET 2019

### Contribution description

As pointed out by @kaspar030 in https://github.com/RIOT-OS/RIOT/pull/10977 an `enum` data type would better represent thread states. In addition, the data type used to store thread states is used inconsistently, e.g. `uint8_t` is used in `thread_t::status`, but `int` is used in [thread_getstatus](http://api.riot-os.org/group__core__thread.html#ga9c1e262507167a576ca0d22abfc6e061) with using the value `-1` as in-band signaling of errors.

This PR introduced the new `enum` data type `thread_state_t` to indicate thread states. It gets rid of the thread state `STATUS_NOT_FOUND` used for in-band signaling by changing the API of `thread_getstatus()` to use out-of-band signaling to indicate success or error. It changes [thread_wakeup](http://api.riot-os.org/group__core__thread.html#gaab65867d92604d57f6efb622586466f4) to provide proper return values (and to get rid of `STATUS_NOT_FOUND`). Finally, the preprocessor macro `STATUS_ON_RUNQUEUE` is replaced by an inline function `sched_is_runnable()`, which also gets rid of the potential pitfall of getting confused which comparator to use with `STATUS_ON_RUNQUEUE`.

### Testing procedure

Compilation and scheduling should still work with this PR.

### Issues/PRs references

https://github.com/RIOT-OS/RIOT/pull/10977, https://github.com/RIOT-OS/RIOT/pull/10967
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * core: Made thread state an enum
  * core: API change of thread_{wakeup,getstatus}
  * core/sched: Added sched_is_runnable()

-- File Changes --

    M core/include/sched.h (36)
    M core/include/thread.h (53)
    M core/sched.c (12)
    M core/thread.c (21)
    M sys/cpp11-compat/thread.cpp (4)
    M sys/ps/ps.c (8)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190211/45585882/attachment-0001.html>

More information about the notifications mailing list