diff --git a/Makefile.dep b/Makefile.dep index a75565ca16..8df1114941 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -610,6 +610,7 @@ endif ifneq (,$(filter schedstatistics,$(USEMODULE))) USEMODULE += xtimer + USEMODULE += sched_cb endif ifneq (,$(filter arduino,$(USEMODULE))) diff --git a/core/include/sched.h b/core/include/sched.h index 4b8c56b6ac..7c94a5d6d4 100644 --- a/core/include/sched.h +++ b/core/include/sched.h @@ -224,14 +224,16 @@ extern schedstat_t sched_pidlist[KERNEL_PID_LAST + 1]; * caller thread */ void init_schedstatistics(void); +#endif /* MODULE_SCHEDSTATISTICS */ +#ifdef MODULE_SCHED_CB /** * @brief Register a callback that will be called on every scheduler run * * @param[in] callback The callback functions the will be called */ void sched_register_cb(void (*callback)(kernel_pid_t, kernel_pid_t)); -#endif /* MODULE_SCHEDSTATISTICS */ +#endif /* MODULE_SCHED_CB */ #ifdef __cplusplus } diff --git a/core/sched.c b/core/sched.c index 0da844bb2b..a4210d12a1 100644 --- a/core/sched.c +++ b/core/sched.c @@ -74,8 +74,10 @@ FORCE_USED_SECTION const uint8_t _tcb_name_offset = offsetof(thread_t, name); #endif -#ifdef MODULE_SCHEDSTATISTICS +#ifdef MODULE_SCHED_CB static void (*sched_cb) (kernel_pid_t active_thread, kernel_pid_t next_thread) = NULL; +#endif +#ifdef MODULE_SCHEDSTATISTICS schedstat_t sched_pidlist[KERNEL_PID_LAST + 1]; #endif @@ -112,7 +114,7 @@ int __attribute__((used)) sched_run(void) #endif } -#ifdef MODULE_SCHEDSTATISTICS +#ifdef MODULE_SCHED_CB if (sched_cb) { /* Use `sched_active_pid` instead of `active_thread` since after `sched_task_exit()` is called `active_thread` is set to NULL while `sched_active_thread` isn't updated until @@ -204,12 +206,14 @@ NORETURN void sched_task_exit(void) cpu_switch_context_exit(); } -#ifdef MODULE_SCHEDSTATISTICS +#ifdef MODULE_SCHED_CB void sched_register_cb(void (*callback)(kernel_pid_t, kernel_pid_t)) { sched_cb = callback; } +#endif +#ifdef MODULE_SCHEDSTATISTICS void sched_statistics_cb(kernel_pid_t active_thread, kernel_pid_t next_thread) { uint32_t now = xtimer_now().ticks32; diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index d110900ff1..b4f769214f 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -70,6 +70,7 @@ PSEUDOMODULES += saul_gpio PSEUDOMODULES += saul_nrf_temperature PSEUDOMODULES += scanf_float PSEUDOMODULES += schedstatistics +PSEUDOMODULES += sched_cb PSEUDOMODULES += semtech_loramac_rx PSEUDOMODULES += sock PSEUDOMODULES += sock_ip