-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core/thread_flags: add thread_flags_wait_any_or_mbox()
#18977
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this saves us from hacks like #19965 I'm all for it!
Can you provide an example how this solves the issue in GNRC?
I have a test setup that provokes the issue quite reliably.
Since we have an ACK and it is agreed that this is proper fix I would suggest we merge before the hard feature freeze today? Any objections? |
I'm sadly afk, otherwise I would suggest that I add a big warning that the function is super mega experimental. That would give some leverage to revert, if needed be. |
e371762
to
04681db
Compare
⬆️ First a rebase without any changes |
thread_flags_wait_any_or_mbox()
thread_flags_wait_any_or_mbox()
4b100e1
to
8c7f4b4
Compare
Done. Care to test? |
8c7f4b4
to
debc55d
Compare
A commit of a different PR sneaked in, sorry |
Hm I applied 17e12fc, c8853f1 and 8a2bc1f but I still see
with unsigned now = ztimer_now(ZTIMER_USEC);
while (1) {
res = gnrc_sock_recv((gnrc_sock_reg_t *)sock, &pkt, timeout, &tmp, &_aux);
/* HACK: gnrc_sock_recv() sometimes returnes -ETIMEDOUT too early */
now = ztimer_now(ZTIMER_USEC) - now;
if (res == -ETIMEDOUT && now < (timeout - timeout/10)) {
timeout -= now;
printf(">>> timeout happened %u µs early <<<\n", timeout);
continue;
}
break;
} (from #19965) |
Can you provide more details on how to reproduce this? Maybe I can even turn this into a unit test. |
It's unfortunately a bit involved for a unit test, but if you check out the |
It would be good to have either this or #19965 backported to the release... |
19990: sys/psa_crypto: allow repeated initialization r=benpicco a=mguetschow ### Contribution description - simple unit test which calls `psa_crypto_init()` twice - fix to no re-initialize key slots (which left them in a broken state) ### Testing procedure - `make -C tests/sys/psa_crypto all test` succeeds - `git checkout HEAD~1 && make -C tests/sys/psa_crypto all test` fails 20011: tests/unittests: add a unit test for ztimer r=benpicco a=maribu ### Contribution description This adds test coverage for removing ztimers with focus on ensuring that offsets are correctly updated on subsequent timers (e.g. not having timers fire too early). ### Testing procedure Run the unit tests (will be done by the CI as well). Maybe also introduce a random bug in `ztimer_remove()` and check if this is indeed caught by the unit tests. ### Issues/PRs references Prompted by #18977 (comment) Co-authored-by: Mikolai Gütschow <[email protected]> Co-authored-by: Marian Buschsieweke <[email protected]>
20011: tests/unittests: add a unit test for ztimer r=benpicco a=maribu ### Contribution description This adds test coverage for removing ztimers with focus on ensuring that offsets are correctly updated on subsequent timers (e.g. not having timers fire too early). ### Testing procedure Run the unit tests (will be done by the CI as well). Maybe also introduce a random bug in `ztimer_remove()` and check if this is indeed caught by the unit tests. ### Issues/PRs references Prompted by #18977 (comment) Co-authored-by: Marian Buschsieweke <[email protected]>
20009: cpu/native: fix bug in periph_timer r=MrKevinWeiss a=maribu ### Contribution description While debugging #18977 (comment) it became obvious that the `periph_timer` in `native` is broken and issues early IRQs. This replaces the use of `setitimer` that cannot use a monotonic clock source with `timer_settime()`. ### Testing procedure I have some non-publishable code that tests if the time an ISR fires in terms of `timer_read()` is no earlier than the time expected. This occasionally triggered with `master`, but I didn't see any of these issues anymore with this PR. I guess I should revive my PR to spice up the periph timer tests and add a polished version of this and let this run for an hour or two. The tests ins `tests/periph/timer*` should still succeed on `native`. (They do for me in a container running `riot/riotbuild`). ### Issues/PRs references Found while debugging #18977 (comment) 20042: dist/tools/uf2: add target to also copy families.json file r=MrKevinWeiss a=MichelRottleuthner ### Contribution description The updated UF2 pkg (#20035) stores the family ID in an external .json file. I overlooked that and flashing fails if this file is not present. This PR fixes it by also copying the json into the tool folder. ### Testing procedure Check if the `feather-nrf52840-sense` can be flashed when the new UF2 pkg is cloned freshly. ### Issues/PRs references Fixes a regression introduced with #20035 Co-authored-by: Marian Buschsieweke <[email protected]> Co-authored-by: Michel Rottleuthner <[email protected]>
ping, I think we would like this in the release |
The new function blocks until either any of given set of flags is set or a message was fetch from the given mbox - whatever comes first.
602b464
to
963d3b3
Compare
I addressed the whitepsace and spelling issues uncovered by I'm almost certain that this does fix a race condition. But the issue at hand in @benpicco's test is then not caused by this. (Nor was it caused by the issue in the My gut tells me that since the race condition has been there for ages, it might be best to solve this puzzle fully before applying a fix that may not work - even if this means the fix will not get in with this release. |
Then I will remove it from the release backport and we can just have a known bug... We are already way over the time. |
#19965 provides a workaround |
Contribution description
This adds
thread_flags_wait_any_or_mbox()
that blocks until any of a given thread flags is set, or a message is retrieved from anmbox
- whatever happens first.This then was used to implement
ztimer_mbox_get_timeout()
(which relates tombox_get()
the same wayztimer_mutex_lock_timeout()
relates tomutex_lock()
).Finally,
ztimer_mbox_get_timeout()
is used in GNRC to fix a nasty race condition.Testing procedure
A test application is provided.
Issues/PRs references
Alternative to #18949 and #19965