[riot-notifications] [RIOT-OS/RIOT] Pr/xtimer mutex lock timeout/already locked (#11543)

Julian Holzwarth notifications at github.com
Fri May 17 17:24:16 CEST 2019


This is the same pr as #10872 with a test.

### Contribution description

Prevent a possible race condition for xtimer_mutex_lock_timeout when _mutex_timeout fires just after the mutex was locked but before the xtimer was removed

The flow
```
int xtimer_mutex_lock_timeout(mutex_t *mutex, uint64_t timeout) {
   ...
    mutex_lock(mutex);
    <- mutex locked ->
    <- _mutex_timeout fires and tries to remove thread from mutex queue ->
    xtimer_remove(&t);
    ...
}
```

### Testing procedure

with the fix the test works, 
```
BOARD=native make -C tests/xtimer_mutex_lock_timeout/ flash test
...
starting test: xtimer mutex lock timeout
OK
> 
```

without the fix 
```
git revert HEAD
BOARD=native make -C tests/xtimer_mutex_lock_timeout/ flash test
...
starting test: xtimer mutex lock timeout
sys/xtimer/xtimer.c:239 => 0x56596856
*** RIOT kernel panic:
FAILED ASSERTION.

*** halted.


native: exiting
Unexpected end of file in expect script at "child.expect("OK")" (tests/xtimer_mutex_lock_timeout/tests/01-run.py:24)
```

You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * REMOVE ME
  * tests/xtimer_mutex_lock_timeout: minimal xtimer_mutex_lock_timeout test
  * xtimer: check in timeout callback if thread blocked on mutex

-- File Changes --

    M sys/xtimer/xtimer.c (18)
    A tests/xtimer_mutex_lock_timeout/Makefile (7)
    A tests/xtimer_mutex_lock_timeout/main.c (76)
    A tests/xtimer_mutex_lock_timeout/tests/01-run.py (29)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11543.patch
https://github.com/RIOT-OS/RIOT/pull/11543.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/11543
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190517/8f56b6bd/attachment-0001.html>


More information about the notifications mailing list