Conversation
`void cpu_switch_context_exit(void)` assigns `sched_active_thread` just before calling `sched_run()`. This is unneeded, as `sched_run()` will updated that anyway. Also generally speaking, changing internal scheduler data from outside the scheduler is a risky thing to do.
|
I saw that @gschorcht recently authored a PR targeting the MSP430 platform that was reviewed by @jcarrano. Maybe one of them has the hardware required to test this PR and could review this one? |
|
@gschorcht: Thanks for pointing that out. The console output I got was So this seems to be working as expected :-) |
|
Looking at the code, this should be tested with enabled module "schedstatistics", with "-DSCHED_TEST_STACK" and with "#define ENABLE_DEBUG 1" in sched.c... |
|
But I agree that if the assignment is necessary, sth is weird. |
|
I ran the test using this modifications: diff --git a/core/sched.c b/core/sched.c
index a5a8d38fb5..bcb0baaad2 100644
--- a/core/sched.c
+++ b/core/sched.c
@@ -37,7 +37,7 @@
#include "xtimer.h"
#endif
-#define ENABLE_DEBUG (0)
+#define ENABLE_DEBUG (1)
#include "debug.h"
#if ENABLE_DEBUG
diff --git a/tests/thread_basic/Makefile b/tests/thread_basic/Makefile
index 61bc51c2c4..b393045c97 100644
--- a/tests/thread_basic/Makefile
+++ b/tests/thread_basic/Makefile
@@ -3,6 +3,7 @@ include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
DISABLE_MODULE += auto_init
+USEMODULE += schedstatistics
TEST_ON_CI_WHITELIST += all
diff --git a/tests/thread_basic/main.c b/tests/thread_basic/main.c
index 457668095a..c3f7335b89 100644
--- a/tests/thread_basic/main.c
+++ b/tests/thread_basic/main.c
@@ -21,7 +21,7 @@
#include <stdio.h>
#include "thread.h"
-char t2_stack[THREAD_STACKSIZE_MAIN];
+char t2_stack[THREAD_STACKSIZE_MAIN + THREAD_EXTRA_STACKSIZE_PRINTF];
void *second_thread(void *arg)
{This is the output. (Apparently the stack of thread 3 is too small of debugging, but I have no idea where that thread is created.) What strikes me is the |
missed that. I'll run it again tomorrow. |
|
OK, did just run it again with |
|
Thanks for reviewing this! |
Contribution description
void cpu_switch_context_exit(void)assignssched_active_threadjust before callingsched_run(). This is unneeded, assched_run()will updated that anyway. Also generally speaking, changing internal scheduler data from outside the scheduler is a risky thing to do.Testing procedure
Flash and run
tests/thread_basicon a MSP430 based board.Issues/PRs references
Spun out of #11226