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

96 Commits

Author SHA1 Message Date
MrKevinWeiss
7a68fb0d5e
*Kconfig*: Remove dep-only Kconfig files 2024-03-26 14:54:22 +01:00
Francisco Molina
20e68fbb68 sys/xtimer: switch default backend to ztimer
With this commit xtimer will always be implemented with ztimer.
The default compat layer will be ztimer_xtimer_compat, so xtimer
calls will be inlined to ZTIMER_USEC, or ZTIMER64_USEC when the
64bit xtimer API is required.

This can be reverted by adding 'xtimer_no_ztimer_default' module
to a build.
2022-03-18 08:23:00 +01:00
Francisco Molina
9260cfb4f0 sys/xtimer: prefer ztimer_xtimer_compat 2022-03-17 14:37:40 +01:00
Francisco Molina
0b1453667e sys/xtimer-ztimer: rework dependecies to ease backend switch
This adds a xtimer_no_ztimer_default that is currently always
selected in Makefile, but that can be switched off in Kconfig.
Removing its inclusion will allow switching the default xtimer
backend to ztimer, while allowing for an easy way back.
2022-03-17 14:37:40 +01:00
Francisco Molina
7227d1bb77 sys/xtimer: move dependencies to xtimer/Makefile.dep 2022-03-17 14:37:40 +01:00
df8086091f sys/ztimer: add ztimer64_xtimer_compat
The ztimer64_xtimer_compat modules implements the whole xtimer api
on top of ztimer64_usec
2022-02-24 09:10:58 +01:00
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
Leandro Lanzieri
3837286750
sys/{x,z}timer/Kconfig: fix compatibility modules 2021-11-09 15:32:33 +01:00
Sebastiaan de Schaetzen
dee65e7ec6 xtimer: fix race condition in xtimer_msg_receive_timeout 2021-04-22 16:31:36 +02:00
Leandro Lanzieri
61a10db288
sys/xtimer/kconfig: fix dependencies 2021-01-18 14:14:13 +01: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
Leandro Lanzieri
4bb0edbbfc
sys/xtimer: Add module to Kconfig 2020-11-06 15:57:53 +01:00
Marian Buschsieweke
9105c60728
Merge pull request #15071 from maribu/untagle_xtimer_mutex
sys/xtimer: untangle from core/mutex
2020-10-28 14:42:11 +01:00
Bas Stottelaar
80d9da90df sys/*: add missing include of assert.h 2020-10-22 11:13:09 +02:00
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
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
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