Skip to content
Snippets Groups Projects
Commit 3ac6d6c8 authored by Sebastian Meiling's avatar Sebastian Meiling
Browse files

schedstats: refine ps output

    - use unsigned int instead of double
parent e7136e2d
No related branches found
No related tags found
No related merge requests found
...@@ -61,10 +61,10 @@ void ps(void) ...@@ -61,10 +61,10 @@ void ps(void)
#endif #endif
"%-9sQ | pri " "%-9sQ | pri "
#ifdef DEVELHELP #ifdef DEVELHELP
"| stack ( used) | base | current " "| stack ( used) | base addr | current "
#endif #endif
#ifdef MODULE_SCHEDSTATISTICS #ifdef MODULE_SCHEDSTATISTICS
"| runtime | switches" "| runtime | switches"
#endif #endif
"\n", "\n",
#ifdef DEVELHELP #ifdef DEVELHELP
...@@ -77,13 +77,23 @@ void ps(void) ...@@ -77,13 +77,23 @@ void ps(void)
void *isr_start = thread_arch_isr_stack_start(); void *isr_start = thread_arch_isr_stack_start();
void *isr_sp = thread_arch_isr_stack_pointer(); void *isr_sp = thread_arch_isr_stack_pointer();
printf("\t - | isr_stack | - - |" printf("\t - | isr_stack | - - |"
" - | %5i (%5i) | %10p | %10p\n", ISR_STACKSIZE, isr_usage, isr_start, isr_sp); " - | %6i (%5i) | %10p | %10p\n", ISR_STACKSIZE, isr_usage, isr_start, isr_sp);
overall_stacksz += ISR_STACKSIZE; overall_stacksz += ISR_STACKSIZE;
if (isr_usage > 0) { if (isr_usage > 0) {
overall_used += isr_usage; overall_used += isr_usage;
} }
#endif #endif
#ifdef MODULE_SCHEDSTATISTICS
uint64_t rt_sum = 0;
for (kernel_pid_t i = KERNEL_PID_FIRST; i <= KERNEL_PID_LAST; i++) {
thread_t *p = (thread_t *)sched_threads[i];
if (p != NULL) {
rt_sum += sched_pidlist[i].runtime_ticks;
}
}
#endif /* MODULE_SCHEDSTATISTICS */
for (kernel_pid_t i = KERNEL_PID_FIRST; i <= KERNEL_PID_LAST; i++) { for (kernel_pid_t i = KERNEL_PID_FIRST; i <= KERNEL_PID_LAST; i++) {
thread_t *p = (thread_t *)sched_threads[i]; thread_t *p = (thread_t *)sched_threads[i];
...@@ -98,9 +108,11 @@ void ps(void) ...@@ -98,9 +108,11 @@ 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 / /* multiply with 100 for percentage and to avoid floats/doubles */
(double) _xtimer_now64() * 100; uint64_t runtime_ticks = sched_pidlist[i].runtime_ticks * 100;
int switches = sched_pidlist[i].schedules; unsigned runtime_major = runtime_ticks / rt_sum;
unsigned runtime_minor = ((runtime_ticks % rt_sum) * 1000) / rt_sum;
unsigned switches = sched_pidlist[i].schedules;
#endif #endif
printf("\t%3" PRIkernel_pid printf("\t%3" PRIkernel_pid
#ifdef DEVELHELP #ifdef DEVELHELP
...@@ -108,10 +120,10 @@ void ps(void) ...@@ -108,10 +120,10 @@ void ps(void)
#endif #endif
" | %-8s %.1s | %3i" " | %-8s %.1s | %3i"
#ifdef DEVELHELP #ifdef DEVELHELP
" | %5i (%5i) | %10p | %10p " " | %6i (%5i) | %10p | %10p "
#endif #endif
#ifdef MODULE_SCHEDSTATISTICS #ifdef MODULE_SCHEDSTATISTICS
" | %6.3f%% | %8d" " | %2d.%03d%% | %8u"
#endif #endif
"\n", "\n",
p->pid, p->pid,
...@@ -123,14 +135,14 @@ void ps(void) ...@@ -123,14 +135,14 @@ void ps(void)
, p->stack_size, stacksz, (void *)p->stack_start, (void *)p->sp , p->stack_size, stacksz, (void *)p->stack_start, (void *)p->sp
#endif #endif
#ifdef MODULE_SCHEDSTATISTICS #ifdef MODULE_SCHEDSTATISTICS
, runtime_ticks, switches , runtime_major, runtime_minor, switches
#endif #endif
); );
} }
} }
#ifdef DEVELHELP #ifdef DEVELHELP
printf("\t%5s %-21s|%13s%6s %5i (%5i)\n", "|", "SUM", "|", "|", printf("\t%5s %-21s|%13s%6s %6i (%5i)\n", "|", "SUM", "|", "|",
overall_stacksz, overall_used); overall_stacksz, overall_used);
# ifdef MODULE_TLSF # ifdef MODULE_TLSF
puts("\nHeap usage:"); puts("\nHeap usage:");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment