diff --git a/src/emu/mux.c b/src/emu/mux.c index 7735dc5..a182c77 100644 --- a/src/emu/mux.c +++ b/src/emu/mux.c @@ -192,6 +192,13 @@ mux_init(struct mux *mux, return -1; } + /* Mark the select channel as dirty, so it runs the select + * callback even if it doesn't have a new value */ + if (chan_dirty(select) != 0) { + err("chan_dirty failed"); + return -1; + } + return 0; } diff --git a/test/emu/nanos6/CMakeLists.txt b/test/emu/nanos6/CMakeLists.txt index 76d9851..4b39909 100644 --- a/test/emu/nanos6/CMakeLists.txt +++ b/test/emu/nanos6/CMakeLists.txt @@ -8,3 +8,4 @@ ovni_test(task-types.c MP) ovni_test(blocking.c MP) ovni_test(ss-mismatch.c SHOULD_FAIL REGEX "thread [0-9]\\+ ended with 1 stacked nanos6 subsystems") +ovni_test(delayed-connect-ss.c) diff --git a/test/emu/nanos6/delayed-connect-ss.c b/test/emu/nanos6/delayed-connect-ss.c new file mode 100644 index 0000000..8a75ec8 --- /dev/null +++ b/test/emu/nanos6/delayed-connect-ss.c @@ -0,0 +1,28 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include "instr_nanos6.h" + +int +main(void) +{ + instr_start(0, 1); + + /* Until here, the nanos6 model has not been connected to the + * patchbay yet. The next event will cause the subsystem mux to + * be connected to the patchbay. We need to ensure that at that + * moment the select channel is evaluated, otherwise the mux + * will remain selecting a null input until the thread state + * changes. */ + + /* FIXME: We should be able to test that after emitting the + * nanos6 event the emulator follows some properties. */ + + instr_nanos6_worker_loop_enter(); + + instr_nanos6_worker_loop_exit(); + + instr_end(); + + return 0; +}