mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
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)))
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += sched_cb
|
||||
endif
|
||||
|
||||
ifneq (,$(filter arduino,$(USEMODULE)))
|
||||
|
@ -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
|
||||
}
|
||||
|
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);
|
||||
#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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user