1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

46 Commits

Author SHA1 Message Date
Marian Buschsieweke
b6b7065ddc
core/rmutex: use atomic utils
Replace use of C11 atomics with atomic utils. This fixes

> error: address argument to atomic operation must be a pointer to a
>        trivially-copyable type ('_Atomic(int) *' invalid)

error when compiling on AVR with LLVM.
2022-01-14 09:52:17 +01:00
Sebastiaan de Schaetzen
dee65e7ec6 xtimer: fix race condition in xtimer_msg_receive_timeout 2021-04-22 16:31:36 +02:00
Marian Buschsieweke
4f36d21957
sys/xtimer: clean up xtimer_mutex_lock_timeout
Use `mutex_lock_cancelable()` and `mutex_cancel()` to implement
`xtimer_mutex_lock_timeout()`.
2020-12-08 22:03:57 +01:00
ae053469d5 sys/xtimer: add missing msg.h include 2020-11-26 13:43:13 +01:00
Marian Buschsieweke
0ce6f2f375
sys/xtimer: untangle from core/mutex
Place a verbatim copy of `_mutex_lock()` as `static` in `xtimer`, so internal
mutex function can be optimized one step at a time without breaking `xtimer`.
2020-09-24 07:42:35 +02:00
Marian Buschsieweke
3b6fa61829
sys: Cleanup access to internal variables
Replace direct accesses to sched_active_thread and sched_active_pid with
the helper functions thread_getpid() and thread_get_active(). This serves
two purposes:

1. It makes accidental writes to those variable from outside core less likely.
2. Casting off the volatile qualifier is now well contained to those two
   functions
2020-08-24 20:28:11 +02:00
JulianHolzwarth
6d6b93afdc sys/xtimer/xtimer.c: new function xtimer_rmutex_lock_timeout()
function tries to acquire a mutex within a timeout
2020-05-04 17:46:31 +02:00
c9c8c98a4b sys/xtimer: introduce xtimer_left_usec() 2020-04-21 11:26:56 +02:00
JulianHolzwarth
dd6e51b1eb core/mutex.c _mutex_lock uses an int pointer
_mutex_lock uses a volatile int pointer for the parameter blocking instead of an int.
2020-03-26 17:26:07 +01:00
JulianHolzwarth
4d85fa16e0 xtimer/xtimer.c: _mutex_remove_thread_from_waiting_queue
This function tries to remove the thread from a mutex waiting queue.
The value pointed to by unlocked will be set to 1 if the thread was removed from the waiting queue otherwise 0.
2020-03-05 19:05:34 +01:00
JulianHolzwarth
bce45fd9d8 xtimer/xtimer.c: xtimer_mutex_lock_timeout fix test
Handling timeout smaller than XTIMER_BACKOFF (the timer spins) when the mutex is already locked.
This fixes the test tests/xtimer_mutex_lock_timeout/main.c:mutex_timeout_spin_locked.
2020-03-05 18:56:35 +01:00
JulianHolzwarth
dfeaea3c36 sys/xtimer/xtimer.c: comment change 2020-03-05 18:45:27 +01:00
Hauke Petersen
58e381979f xtimer: add xtimer_set_timeout_flag64() 2020-02-13 15:37:14 +01:00
JulianHolzwarth
70923d0c1b xtimer/xtimer.c:_mutex_timeout() improved
no longer into the "if" when the mutex is free
2020-01-22 18:40:29 +01:00
Hyungsin
387344775b sys: xtimer concurrency/robustness improvement 2020-01-10 10:06:16 -08:00
MichelRottleuthner
272079c89e
Merge pull request #11992 from JulianHolzwarth/pr/xtimer_mutex_lock_timeout/first_fix
sys/xtimer/xtimer.c: _mutex_timeout() bug fix for race condition
2019-12-04 10:43:20 +01:00
JulianHolzwarth
7cd3e8b73e xtimer/xtimer.c:_mutex_timeout() improved
no longer into the "if" when the mutex is free
2019-11-27 14:49:16 +01:00
Pieter Willemsen
f3b13cf90c xtimer: check in timeout callback if thread blocked on mutex
Prevent a possible race condition 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 */
    /* DEBUG: simulate callback call between lock and remove */
    xtimer_spin(xtimer_ticks_from_usec(timeout*2));
    xtimer_remove(&t);
    ...
}
2019-11-27 14:48:51 +01:00
2ea1b24eae sys/xtimer: fix typos 2019-11-23 22:39:38 +01:00
Marian Buschsieweke
cd1ce6b98d
sys/xtimer: Remove dependency to core_msg
When module `core_msg` is not used, `xtimer` now no longer provides the features
related to messages. This allows using `xtimer` without `core_msg`.
2019-10-31 19:55:50 +01:00
JulianHolzwarth
c1f58186cb xtimer/xtimer.c: sched_switch instead of yield
because of pr #11759: not all boards check for is_in_irq when thread_yield_higher
2019-08-09 17:29:40 +02:00
JulianHolzwarth
1bcb4fcc5f xtimer/xtimer.c: _mutex_timeout improvements
Only yields and change threads status when thread was removed from mutex list.
2019-08-09 17:29:40 +02:00
JulianHolzwarth
a321dfc51d xtimer/xtimer.c: ensure modifing mutex is done with interrupt disabled
if xtimer_set spins the callback is executed in the thread context.

comment to explain irq_disable
and when this line could be removed
(when xtimer stops executing the callback funtion from thread context)
2019-08-09 17:28:54 +02:00
JulianHolzwarth
1fff551d7c xtimer/xtimer.c: fix timeout is volatile
timeout is modified from interupt context so must be volatile
2019-06-05 14:20:16 +02:00
JulianHolzwarth
301d88c04a xtimer/xtimer.c document mutex_thread_t
comment for mutex_thread_t
2019-06-05 14:16:30 +02:00
069a1f6e8b sys/xtimer: make xtimer_mutex_lock_timeout() actually use us arg 2019-03-12 16:09:04 +01:00
7d013eb2b6 sys: fix doxygen grouping 2018-06-11 19:12:02 +02:00
35f329e05c sys/xtimer: add xtimer_set_timeout_flag() 2017-09-01 23:54:28 +02:00
Oleg Hahm
9a38c1085c Merge pull request #6428 from OTAkeys/fix/xtimer_mutex_infinite_loop
xtimer: fix mutex unlocking in _mutex_timeout
2017-01-20 16:43:38 +01:00
Vincent Dupont
eacffdf490 xtimer: fix mutex unlocking in _mutex_timeout 2017-01-19 18:26:52 +01:00
Oleg Hahm
4f4214235b timex: unambiguous time conversion macros 2017-01-19 13:18:08 +01:00
Victor Arino
17d6d2a5b5 sys/xtimer: implement mutex lock with timeout 2017-01-12 13:20:26 +01:00
Joakim Nohlgård
63e91151cd xtimer: Add tick conversion 2016-11-28 11:00:42 +01:00
Joakim Nohlgård
4449ba4933 xtimer: Refactor xtimer_usleep_until and rename to xtimer_periodic_wakeup
Rewrote conditions for improved readability, and removed magic number 512
2016-07-29 13:05:02 +02:00
Joakim Nohlgård
7c70d3bc4f xtimer: Add Eistec copyright and author 2016-07-06 22:23:05 +02:00
7718f114cb all: remove pointer casts for msg.content.ptr 2016-06-02 23:13:42 +02:00
Ian Martin
31c6bcc4d8 xtimer: return after xtimer_spin() when within an ISR 2016-05-10 13:30:40 -04:00
DipSwitch
0bb4748a94 core: Fix/refactor function naming in core/incude/irq.h 2016-03-20 16:47:34 +01:00
Oleg Hahm
0ddd6ec15e xtimer: implement xtimer_msg_receive_timeout 2015-11-23 20:45:25 +01:00
725473d9a6 sys: xtimer: make xtimer use div.h 2015-10-12 23:25:59 +02:00
Joakim Nohlgård
7f254c6d12 sys/xtimer: rename _ms_to_sec -> _us_to_sec to reflect actual functionality
The function divides the argument by 1000000, (microsecond to seconds)
2015-09-28 14:23:16 +02:00
Oleg Hahm
38148c2d48 xtimer: initialize struct members
The xtimer_t struct members target and long_target are used in _is_set() function in xtimer_remove(), but will be uninitialized.
2015-09-20 02:00:55 +02:00
a719e7d61f sys: xtimer: some updates
- more robust underflow protection in xtimer_usleep_until()
- use relative target in xtimer_spin()
- honour reference in isr when spinning until timer target
- add XTIMER_BACKOFF to xtimer_spin_until() target when backing off in
  _timer_set_absolute()
- doxygen updates
2015-09-16 12:34:31 +02:00
40812e722e sys: xtimer: use relative spin in absolute set functions 2015-09-16 11:13:42 +02:00
e27ce2465f sys: xtimer: add xtimer_wakeup64 2015-09-16 10:58:54 +02:00
808a8bc899 sys: xtimer: introduce new timer subsystem 2015-08-25 13:20:35 +02:00