cpu/native: use async read for stdio_read()
Contribution description
The real_read() function will block the thread but won't preempt it.
That means all other threads on the same (or higher) priority level are blocked as RIOT still considers the thread that called stdio_read() as running.
Use async_read/isrpipe to properly block the thread when reading from stdin.
Testing procedure
Run a 2nd thread with the same priority as the main thread:
--- a/tests/shell/main.c
+++ b/tests/shell/main.c
@@ -132,10 +132,28 @@ static int _xfa_test2(int argc, char **argv)
SHELL_COMMAND(xfa_test2, "xfa test command 2", _xfa_test2);
SHELL_COMMAND(xfa_test1, "xfa test command 1", _xfa_test1);
+#include "thread.h"
+#include "ztimer.h"
+
+static char _stack[1024];
+
+static void *_func(void *arg)
+{
+ while (1) {
+ ztimer_sleep(ZTIMER_MSEC, 1000);
+ puts(arg);
+ }
+
+ return NULL;
+}
+
int main(void)
{
printf("test_shell.\n");
+ thread_create(_stack, sizeof(_stack), THREAD_PRIORITY_MAIN, THREAD_CREATE_STACKTEST,
+ _func, "Hello shell", "periodic");
+
/* define own shell commands */
shell_run_once(shell_commands, line_buf, sizeof(line_buf));
On master the periodic "Hello shell" message is never printed.
Issues/PRs references
fixes #16834
Murdock results
:x: FAILED
41ce809cfe43eadd0a2259edfee91c9b00e770e0 sys/net/telnet: align API with stdio API
Build failures (10)
| Application | Target | Toolchain | Runtime (s) | Worker |
|---|---|---|---|---|
| tests/pkg/libschc | native64 | llvm | 290.08 | comsys-minion-0 |
| tests/pkg/libschc | native | llvm | 290.10 | mobi7 |
| tests/pkg/libschc | native | gnu | 290.01 | mobi7 |
| tests/pkg/libschc | native64 | gnu | 290.11 | sarajevo |
| tests/sys/congure_quic | native64 | gnu | 290.01 | breeze |
| tests/sys/congure_quic | native | llvm | 290.01 | mobi3 |
| tests/sys/congure_quic | native64 | llvm | 290.10 | mobi6 |
| tests/sys/congure_quic | native | gnu | 290.08 | comsys-minion-0 |
| tests/sys/congure_test | native | gnu | 290.10 | mobi6 |
| tests/sys/congure_test | native64 | llvm | 290.10 | mobi6 |
Test failures (21)
| Application | Target | Toolchain | Runtime (s) | Worker |
|---|---|---|---|---|
| tests/periph/flashpage | native64 | gnu | 0.00 | mobi6 |
| tests/periph/gpio | native64 | gnu | 0.00 | mobi6 |
| tests/periph/gpio | native | llvm | 0.00 | mobi6 |
| tests/pkg/flatbuffers | native | gnu | 0.00 | mobi6 |
| tests/pkg/uzlib | native64 | gnu | 0.00 | mobi6 |
| tests/pkg/uzlib | native64 | llvm | 0.00 | mobi3 |
| tests/sys/atomic_utils | native | gnu | 0.00 | mobi6 |
| tests/sys/atomic_utils | native64 | gnu | 0.00 | mobi6 |
| tests/sys/atomic_utils | native | llvm | 0.00 | mobi6 |
| tests/sys/cpp11_mutex | native | gnu | 0.00 | comsys-minion-0 |
| tests/sys/rng | native | gnu | 0.00 | breeze |
| tests/sys/rng | native | llvm | 0.00 | comsys-minion-0 |
| tests/sys/rng | native64 | gnu | 0.00 | mobi6 |
| tests/sys/senml_cbor | native64 | llvm | 0.00 | sarajevo |
| tests/sys/senml_cbor | native64 | gnu | 0.00 | mobi3 |
| tests/sys/senml_cbor | native | gnu | 0.00 | mobi6 |
| tests/sys/senml_cbor | native | llvm | 0.00 | mobi6 |
| tests/sys/senml_phydat | native | gnu | 0.00 | mobi6 |
| tests/sys/senml_phydat | native | llvm | 0.00 | breeze |
| tests/sys/struct_tm_utility | native64 | gnu | 0.00 | mobi6 |
Artifacts
@leandrolanzieri do you have an idea how to solve the Kconfig issue?
Please squash.
CI will still fail as some tests that use float will now preempt, which triggers #495