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

80 Commits

Author SHA1 Message Date
Marian Buschsieweke
6deb89f887
sys/xtimer: assert() successful initialized
Use an `assert()` to make sure that `periph_timer` was successfully initialized.
2020-09-29 11:52:26 +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
Martine S. Lenders
085c62ecdc
xtimer_core: piggy-back style fixes 2020-04-10 12:42:32 +02:00
Martine S. Lenders
212fe15786
xtimer: set now pointer correctly in _update_short_timers() loop
This fixes `xtimer` to use `xtimer_now64()` instead of `xtimer_now()`
for updating the `*now` variable during the iteration in
`_update_short_timers()` function. The same function is used to
initialize `*now` in `_timer_callback()` below.

While using `xtimer_now()` in this iteration step does not hinder the
proper execution of all timers in the short term timers (for those the
`xtimer` module only looks at the `start_time` member, not the
`long_start_time` member) at least for the current long term time window
(I did not test higher cases), it sets the `long_start_time` member to 0
for all timers following in the list of timers after this iteration
step. However, external modules that rely on this to be correct,
e.g. evtimer [1], fail their calculations when trying to compare to
the current value to `xtimer_now64()`.

[1] https://github.com/RIOT-OS/RIOT/blob/11f3d68/sys/evtimer/evtimer.c#L118-L121

Co-Authored-By: Cenk Gündoğan <mail+dev@gundogan.net>
2020-04-10 00:02:33 +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
ed316309c8
Merge pull request #11874 from kaspar030/ztimer
sys/ztimer: initial import
2020-03-06 09:46:27 +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
dd218333c2 sys/ztimer: add xtimer_on_ztimer
This commit adds logic to make xtimer use ztimer_usec as backend
(instead of periph_timer). This allows ztimer_usec and xtimer to
coexist. It also allows xtimer to profit from eventually implemented
power mode blocking in ztimer's periph_timer backend.
2020-03-04 12:44:03 +01:00
Hauke Petersen
58e381979f xtimer: add xtimer_set_timeout_flag64() 2020-02-13 15:37:14 +01:00
Hyungsin
eadd4c9f72 sys/xtimer: compare two offsets rather than absolute times 2020-01-29 10:52:43 -08: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
Josarn
672368954e xtimer: timer & target overflow, hang resolved.
1. When the 32 bit target of the xtimer overflowed the timer was not placed in the right list.
2. When the hardware timer overflowed the comparison was wrong for setting next target.

3. Backoff condition
2018-11-01 16:48:20 +01:00
josar
f770d17e12 xtimer_core: uncrustify 2018-09-18 16:13:18 +02:00
7d013eb2b6 sys: fix doxygen grouping 2018-06-11 19:12:02 +02:00
Martine Lenders
0a0bb86f4a posix: move time functions to their own module 2017-11-12 19:55:57 +01:00
35f329e05c sys/xtimer: add xtimer_set_timeout_flag() 2017-09-01 23:54:28 +02:00
Joakim Nohlgård
8e10e6e3fa xtimer: Use {} for empty while loops 2017-06-10 06:34:24 +02:00
185c7ac11b some (ptr == 0) -> (ptr == NULL) fixes (found by coccinelle) 2017-04-20 23:31:32 +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
Martine Lenders
712bd09b2c xtimer: fix for DEBUG 2017-01-18 19:38:05 +01:00
Oleg Hahm
24c205d3a3 xtimer: fix formatter for xtimer_now in DEBUG 2017-01-18 16:20:02 +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
da8cd11816 xtimer: Move xtimer_spin_until into xtimer_core.c 2016-07-06 22:23:07 +02:00
Joakim Nohlgård
4fe674f746 xtimer: Add missing space 2016-07-06 22:23:06 +02:00
Joakim Nohlgård
7c70d3bc4f xtimer: Add Eistec copyright and author 2016-07-06 22:23:05 +02:00
Joakim Nohlgård
4d862955c2 xtimer: Rename XTIMER -> XTIMER_DEV 2016-07-06 22:23:04 +02:00
Joakim Nohlgård
2f832117f8 xtimer: prefix _lltimer_now, _lltimer_mask with _xtimer 2016-07-06 22:23:04 +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