[riot-notifications] [RIOT-OS/RIOT] core/schedstatistics: fix call to uninitialized xtimer (#11781)

Gaëtan Harter notifications at github.com
Mon Jul 29 18:08:38 CEST 2019


cladmi commented on this pull request.



> @@ -221,3 +202,37 @@ NORETURN void sched_task_exit(void)
     sched_active_thread = NULL;
     cpu_switch_context_exit();
 }
+
+#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;
+
+    /* There is no active thread the first time the callback is executed */
+    if (pid_is_valid(active_thread)) {

After reviewing the other one, I also re-thought about that one, I think that now it is always valid.

The reason it was not valid, is that the code for statistics was also called on the bootstrap `sched_run` where there was not thread before.
As now, `register_cb` is done inside `kernel_init`, `sched_statistics_cb` can only be called when `active_thread` is valid.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11781#pullrequestreview-267886048
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190729/e2308cc5/attachment.htm>


More information about the notifications mailing list