1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 10:32:44 +01:00

sys/ps/ps.c: enabled runtime in usec for schedstatistics

This commit is contained in:
Jan Mohr 2021-05-12 15:27:05 +02:00
parent 33539f137a
commit 435796ccaa

View File

@ -12,19 +12,21 @@
* @file
* @brief UNIX like ps command
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @note The entry 'runtime_usec' in 'MODULE_SCHEDSTATISTICS' is limited
* to 2**32 microseconds. So the entry gets reset after ~1.2 hours.
* @}
*/
#include <stdio.h>
#include <assert.h>
#include "thread.h"
#include "sched.h"
#include "thread.h"
#include "sched.h"
#ifdef MODULE_SCHEDSTATISTICS
#include "schedstatistics.h"
#include "xtimer.h"
#endif
#ifdef MODULE_TLSF_MALLOC
@ -50,7 +52,7 @@ void ps(void)
"| stack ( used) ( free) | base addr | current "
#endif
#ifdef MODULE_SCHEDSTATISTICS
"| runtime | switches"
"| runtime | switches | runtime_usec "
#endif
"\n",
#ifdef CONFIG_THREAD_NAMES
@ -89,11 +91,11 @@ void ps(void)
thread_t *p = thread_get(i);
if (p != NULL) {
thread_status_t state = thread_get_status(p); /* copy state */
const char *sname = thread_state_to_string(state); /* get state name */
const char *queued = thread_is_active(p) ? "Q" : "_"; /* get queued flag */
thread_status_t state = thread_get_status(p); /* copy state */
const char *sname = thread_state_to_string(state); /* get state name */
const char *queued = thread_is_active(p) ? "Q" : "_"; /* get queued flag */
#ifdef DEVELHELP
int stacksz = p->stack_size; /* get stack size */
int stacksz = p->stack_size; /* get stack size */
overall_stacksz += stacksz;
int stack_free = thread_measure_stack_free(p->stack_start);
stacksz -= stack_free;
@ -102,6 +104,7 @@ void ps(void)
#ifdef MODULE_SCHEDSTATISTICS
/* multiply with 100 for percentage and to avoid floats/doubles */
uint64_t runtime_ticks = sched_pidlist[i].runtime_ticks * 100;
xtimer_ticks32_t xtimer_ticks = {sched_pidlist[i].runtime_ticks};
unsigned runtime_major = runtime_ticks / rt_sum;
unsigned runtime_minor = ((runtime_ticks % rt_sum) * 1000) / rt_sum;
unsigned switches = sched_pidlist[i].schedules;
@ -115,7 +118,7 @@ void ps(void)
" | %6i (%5i) (%5i) | %10p | %10p "
#endif
#ifdef MODULE_SCHEDSTATISTICS
" | %2d.%03d%% | %8u"
" | %2d.%03d%% | %8u | %10"PRIu32" "
#endif
"\n",
p->pid,
@ -128,7 +131,7 @@ void ps(void)
(void *)p->stack_start, (void *)p->sp
#endif
#ifdef MODULE_SCHEDSTATISTICS
, runtime_major, runtime_minor, switches
, runtime_major, runtime_minor, switches, xtimer_usec_from_ticks(xtimer_ticks)
#endif
);
}