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

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


cladmi commented on this pull request.



> +#ifdef MODULE_SCHED_CB
+void sched_register_cb(void (*callback)(uint32_t, uint32_t))
+{
+    sched_cb = callback;
+}
+#endif
+
+#ifdef MODULE_SCHEDSTATISTICS
+void sched_statistics_cb(uint32_t active_thread, uint32_t next_thread) {
+
+    uint32_t now = xtimer_now().ticks32;
+
+    if((thread_getstatus(active_thread) != STATUS_STOPPED) && \
+       (thread_getstatus(active_thread) != STATUS_NOT_FOUND)) {
+        schedstat_t *active_stat = &sched_pidlist[active_thread];
+        if (active_stat->laststart) {

I added some debug and the first statistics will indeed be dropped:

On an `iotlab-m3`

```
init_schedstatistics now(): 2
main(): This is RIOT! (Version: 2019.07-devel-841-g9023b7-pr/riot/11781/fix_call_to_uninitialized_xtimer)
sched_statistics_cb laststart=0 now(): 3025
Creating thread #0, next=1
Creating thread #1, next=2
Creating thread #2, next=3
Creating thread #3, next=4
Creating thread #4, next=0
```

-- 
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#discussion_r308324080
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190729/41577c55/attachment-0001.htm>


More information about the notifications mailing list