[riot-notifications] [RIOT-OS/RIOT] sys/xtimer/xtimer.c: _mutex_timeout() clean ups (#11807)

Julian Holzwarth notifications at github.com
Fri Jul 5 18:00:52 CEST 2019

The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.

### Contribution description

Put here the description of your contribution:
- describe which part(s) of RIOT is (are) involved
- if it's a bug fix, describe the bug that it solves and how it is solved
- you can also give more information to reviewers about how to test your changes
This pr prepares for bug fixes and improvements of `xtimer.c:xtimer_mutex_lock_timeout() ` (the tracking pr: #11660 )

This pr improves the _mutex_timeout() function. 
It uses now `sched_switch` instead of `thread_yield_higher`. (https://github.com/RIOT-OS/RIOT/pull/11660#discussion_r298597694, #11759)
Only call `sched_switch` (`thread_yield_higher` before) when the thread was unlocked.
And ensure interrupt are disabled because it modifies a mutex. (if `xtimer_set` spins the callback is executed in the thread context.)

This pr also changes the comment of `sys/include/xtimer.h: xtimer_mutex_lock_timeout()`

### Testing procedure

Details steps to test your contribution:
- which test/example to compile for which board and is there a 'test' command
- how to know that it was not working/available in master
- the expected success test output

`BOARD=native make -C tests/xtimer_mutex_lock timeout/ flash test`

> mutex_timeout_n_spin_unlocked
starting test: xtimer mutex lock timeout
> mutex_timeout_n_spin_locked
starting test: xtimer mutex lock timeout

### Issues/PRs references

Examples: Fixes #1234. See also #5678. Depends on PR #9876.

Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.
 the tracking pr: #11660
reason for sched_switch instead of thread_yield_higher: #11759, https://github.com/RIOT-OS/RIOT/pull/11660#discussion_r298597694
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * sys/include/xtimer.h: xtimer_mutex_lock_timeout() change comment
  * xtimer/xtimer.c: ensure modifing mutex is done with interrupt disabled
  * xtimer/xtimer.c: _mutex_timeout improvements
  * xtimer/xtimer.c: sched_switch instead of yield

-- File Changes --

    M sys/include/xtimer.h (2)
    M sys/xtimer/xtimer.c (17)

-- 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/20190705/e0c9cd30/attachment-0001.html>

More information about the notifications mailing list