core/sched: separate sched_cb from schedstatistics
This commit is contained in:
parent
3d62fa05b8
commit
fc58ebbd97
@ -610,6 +610,7 @@ endif
|
|||||||
|
|
||||||
ifneq (,$(filter schedstatistics,$(USEMODULE)))
|
ifneq (,$(filter schedstatistics,$(USEMODULE)))
|
||||||
USEMODULE += xtimer
|
USEMODULE += xtimer
|
||||||
|
USEMODULE += sched_cb
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter arduino,$(USEMODULE)))
|
ifneq (,$(filter arduino,$(USEMODULE)))
|
||||||
|
|||||||
@ -224,14 +224,16 @@ extern schedstat_t sched_pidlist[KERNEL_PID_LAST + 1];
|
|||||||
* caller thread
|
* caller thread
|
||||||
*/
|
*/
|
||||||
void init_schedstatistics(void);
|
void init_schedstatistics(void);
|
||||||
|
#endif /* MODULE_SCHEDSTATISTICS */
|
||||||
|
|
||||||
|
#ifdef MODULE_SCHED_CB
|
||||||
/**
|
/**
|
||||||
* @brief Register a callback that will be called on every scheduler run
|
* @brief Register a callback that will be called on every scheduler run
|
||||||
*
|
*
|
||||||
* @param[in] callback The callback functions the will be called
|
* @param[in] callback The callback functions the will be called
|
||||||
*/
|
*/
|
||||||
void sched_register_cb(void (*callback)(kernel_pid_t, kernel_pid_t));
|
void sched_register_cb(void (*callback)(kernel_pid_t, kernel_pid_t));
|
||||||
#endif /* MODULE_SCHEDSTATISTICS */
|
#endif /* MODULE_SCHED_CB */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
10
core/sched.c
10
core/sched.c
@ -74,8 +74,10 @@ FORCE_USED_SECTION
|
|||||||
const uint8_t _tcb_name_offset = offsetof(thread_t, name);
|
const uint8_t _tcb_name_offset = offsetof(thread_t, name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULE_SCHEDSTATISTICS
|
#ifdef MODULE_SCHED_CB
|
||||||
static void (*sched_cb) (kernel_pid_t active_thread, kernel_pid_t next_thread) = NULL;
|
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];
|
schedstat_t sched_pidlist[KERNEL_PID_LAST + 1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -112,7 +114,7 @@ int __attribute__((used)) sched_run(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_SCHEDSTATISTICS
|
#ifdef MODULE_SCHED_CB
|
||||||
if (sched_cb) {
|
if (sched_cb) {
|
||||||
/* Use `sched_active_pid` instead of `active_thread` since after `sched_task_exit()` is
|
/* 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
|
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();
|
cpu_switch_context_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_SCHEDSTATISTICS
|
#ifdef MODULE_SCHED_CB
|
||||||
void sched_register_cb(void (*callback)(kernel_pid_t, kernel_pid_t))
|
void sched_register_cb(void (*callback)(kernel_pid_t, kernel_pid_t))
|
||||||
{
|
{
|
||||||
sched_cb = callback;
|
sched_cb = callback;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODULE_SCHEDSTATISTICS
|
||||||
void sched_statistics_cb(kernel_pid_t active_thread, kernel_pid_t next_thread)
|
void sched_statistics_cb(kernel_pid_t active_thread, kernel_pid_t next_thread)
|
||||||
{
|
{
|
||||||
uint32_t now = xtimer_now().ticks32;
|
uint32_t now = xtimer_now().ticks32;
|
||||||
|
|||||||
@ -70,6 +70,7 @@ PSEUDOMODULES += saul_gpio
|
|||||||
PSEUDOMODULES += saul_nrf_temperature
|
PSEUDOMODULES += saul_nrf_temperature
|
||||||
PSEUDOMODULES += scanf_float
|
PSEUDOMODULES += scanf_float
|
||||||
PSEUDOMODULES += schedstatistics
|
PSEUDOMODULES += schedstatistics
|
||||||
|
PSEUDOMODULES += sched_cb
|
||||||
PSEUDOMODULES += semtech_loramac_rx
|
PSEUDOMODULES += semtech_loramac_rx
|
||||||
PSEUDOMODULES += sock
|
PSEUDOMODULES += sock
|
||||||
PSEUDOMODULES += sock_ip
|
PSEUDOMODULES += sock_ip
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user