Skip to content
Snippets Groups Projects
Commit 6d5b9551 authored by Vincent Dupont's avatar Vincent Dupont
Browse files

ps: fix schedstatistics

Fix xtimer_now() usage and fix columns alignment in ps command when
module schedstatistics is used.
parent c23d624d
Branches
No related tags found
No related merge requests found
...@@ -179,10 +179,10 @@ NORETURN void sched_task_exit(void); ...@@ -179,10 +179,10 @@ NORETURN void sched_task_exit(void);
* Scheduler statistics * Scheduler statistics
*/ */
typedef struct { typedef struct {
unsigned int laststart; /**< Time stamp of the last time this thread was uint64_t laststart; /**< Time stamp of the last time this thread was
scheduled to run */ scheduled to run */
unsigned int schedules; /**< How often the thread was scheduled to run */ unsigned int schedules; /**< How often the thread was scheduled to run */
unsigned long runtime_ticks; /**< The total runtime of this thread in ticks */ uint64_t runtime_ticks; /**< The total runtime of this thread in ticks */
} schedstat; } schedstat;
/** /**
......
...@@ -101,7 +101,7 @@ int __attribute__((used)) sched_run(void) ...@@ -101,7 +101,7 @@ int __attribute__((used)) sched_run(void)
} }
#ifdef MODULE_SCHEDSTATISTICS #ifdef MODULE_SCHEDSTATISTICS
unsigned long time = _xtimer_now(); uint64_t now = _xtimer_now64();
#endif #endif
if (active_thread) { if (active_thread) {
...@@ -118,17 +118,17 @@ int __attribute__((used)) sched_run(void) ...@@ -118,17 +118,17 @@ int __attribute__((used)) sched_run(void)
#ifdef MODULE_SCHEDSTATISTICS #ifdef MODULE_SCHEDSTATISTICS
schedstat *active_stat = &sched_pidlist[active_thread->pid]; schedstat *active_stat = &sched_pidlist[active_thread->pid];
if (active_stat->laststart) { if (active_stat->laststart) {
active_stat->runtime_ticks += time - active_stat->laststart; active_stat->runtime_ticks += now - active_stat->laststart;
} }
#endif #endif
} }
#ifdef MODULE_SCHEDSTATISTICS #ifdef MODULE_SCHEDSTATISTICS
schedstat *next_stat = &sched_pidlist[next_thread->pid]; schedstat *next_stat = &sched_pidlist[next_thread->pid];
next_stat->laststart = time; next_stat->laststart = now;
next_stat->schedules++; next_stat->schedules++;
if (sched_cb) { if (sched_cb) {
sched_cb(time, next_thread->pid); sched_cb(now, next_thread->pid);
} }
#endif #endif
......
...@@ -61,7 +61,7 @@ void ps(void) ...@@ -61,7 +61,7 @@ void ps(void)
#endif #endif
"%-9sQ | pri " "%-9sQ | pri "
#ifdef DEVELHELP #ifdef DEVELHELP
"| stack ( used) | base | current " "| stack ( used) | base | current "
#endif #endif
#ifdef MODULE_SCHEDSTATISTICS #ifdef MODULE_SCHEDSTATISTICS
"| runtime | switches" "| runtime | switches"
...@@ -98,7 +98,8 @@ void ps(void) ...@@ -98,7 +98,8 @@ void ps(void)
overall_used += stacksz; overall_used += stacksz;
#endif #endif
#ifdef MODULE_SCHEDSTATISTICS #ifdef MODULE_SCHEDSTATISTICS
double runtime_ticks = sched_pidlist[i].runtime_ticks / (double) xtimer_now() * 100; double runtime_ticks = sched_pidlist[i].runtime_ticks /
(double) _xtimer_now64() * 100;
int switches = sched_pidlist[i].schedules; int switches = sched_pidlist[i].schedules;
#endif #endif
printf("\t%3" PRIkernel_pid printf("\t%3" PRIkernel_pid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment