xtimer/xtimer.c: xtimer_rmutex_lock_timeout#11977
xtimer/xtimer.c: xtimer_rmutex_lock_timeout#11977MichelRottleuthner merged 5 commits intoRIOT-OS:masterfrom
Conversation
87c89f4 to
4adf07d
Compare
4adf07d to
581ca43
Compare
581ca43 to
a09343e
Compare
b915196 to
3d8f509
Compare
|
@MichelRottleuthner Can you look at this? |
vincent-d
left a comment
There was a problem hiding this comment.
The implementation of the feature looks good, it's how I did in #13706 (I missed this one) and it works as expected.
I guess someone more used to writing RIOT tests might want to take another look at the test. Looks good to me.
|
I had a quick look at the tests and they do look fine to me. However, Murdock is not happy appearently :( |
|
This PR seems to suffer from some C/C++ atomics clash. @maribu I saw that you worked on C++ wrapper related things - do you have an Idea what's going on there? |
C11 atomics and C++ atomics are incompatible. There is no way of accessing C++ atomics variables from C and C11 atomics form C++. Access to C11 atomics from C++ would only be possible by writing C functions (no header-only Luckily, there is currently no use case where C++ code needs to access C11 atomics in RIOT, except for knowing the size and alignment requirements of the C11 atomics for allocation. E.g. in order to allocate an
This PR uses the wrapper only for declaring |
|
Thanks a lot for the detailed information @maribu. Do you see any reason against adding the following to diff --git a/sys/include/c11_atomics_compat.hpp b/sys/include/c11_atomics_compat.hpp
index fbb6ef1aa..dff371fb7 100644
--- a/sys/include/c11_atomics_compat.hpp
+++ b/sys/include/c11_atomics_compat.hpp
@@ -36,7 +36,9 @@
* atomic_int foo = ATOMIC_VAR_INIT(42);
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
+#ifndef ATOMIC_VAR_INIT
#define ATOMIC_VAR_INIT(x) { x }
+#endif
/**
* @brief Type with the same alignment and size as `atomic_bool` |
tl;dr: I'd say it's fine. In detal: It is a pity that both C11 atomics and C++ atomics have the very same macro to initialize their atomic variables. If both C11 atomics and C++ atomics are included and the define is actually different (which is not the case for the ESP toolchains), this would cause issues. However, this macro is only needed for legacy toolchains that lack full C11 atomic / C++11 atomic support. (With full C11 atomic support you don't need to do |
There was a problem hiding this comment.
I ran the test on native, esp32, pba-d-01-kw2x, and nucleo-f103rb.
While it works on native, it seems to fail on all real boards because of the following output hiccup:
> rmutex_timeout_long_locked_low
rmutex_timeout_long_locked_low
starting test: xtimer rmutex lock timeout
THREAD low prio: start
MAIN THREAD: calling xtimer_rmutex_lock_timeout
THREAD low error: rmutex timed out
MAIN THREAD: waiting for created thread to end
p waiting for crTHREAD low prio: exiting low
> Timeout in expect script at "child.expect("OK")" (tests/xtimer_rmutex_lock_timeout/tests/01-run.py:32)
I also think it would be worth to strip away any output that is not absolutely necessary. That way we should get rid of (at least some) BOARD_INSUFFICIENT_MEMORY entries.
For automatic tests, covering more boards should IMO have much higher priority than "a bit more self-explaining shell interface".
E.g. the test command "rmutex_timeout_long_locked_low" and its description "lock low-prio-locked-rmutex from high-prio-thread (no-spin timeout)" is (and can never be) precise on describing the tested case in detail. Instead something like "t1" and "see main.c" would be a lot shorter and more explicit. When failing, everyone will look at the the code anyway.
People who run the test manually and want to know what the test is doing in detail also wouldn't get this from the command description currently.
Proposal: only keep outputs needed for test execution and result interpretation of the test script and move detailed descriptions to code comments.
[Edit]:
please also adapt the commit messages of sys/include/vfs.h: fix mulle atomic problem and sys/include/c11_atomics_compat.hpp: fix murdock problem to something more explicit ;)
|
@MichelRottleuthner reduced the output. Also what should the commit message say? |
|
Also can i squash? |
7a5efa6 to
56218c9
Compare
|
reduced size |
|
Thanks for reducing the size. It should fit all platforms now. Though, you forgot to update the BOARD_INSUFFICIENT_MEMORY list accordingly. And you also didn't change the commit messages as we agreed on before ;) |
function tries to acquire a mutex within a timeout
this implements a new test for sys/xtimer/xtimer.c: xtimer_rmutex_lock_timeout The test is similar to tests/xtimer_mutex_lock_timeout
to solve a problem with c and c++ atomic
Fixes a problem with redefining ATOMIC_VAR_INIT for esp32
56218c9 to
6c8b1f1
Compare
|
@MichelRottleuthner ping |
MichelRottleuthner
left a comment
There was a problem hiding this comment.
I ran the provided test again on native, esp32, pba-d-01-kw2x, and nucleo-f103rb: it works as expected now.
All requests were addressed -> ACK
Contribution description
This pr adds a new function
xtimer_rmutex_lock_timeout. The function tries to acquire armutexwithin a timeout and returns if it was successful. The function usesxtimer_mutex_lock_timeout.Testing procedure
BOARD=native make -C tests/xtimer_rmutex_lock_timeout/ flash testit outputs before #11660:
after #11660 output:
Issues/PRs references
depends on #11660