-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ps: fix schedstatistics #6975
ps: fix schedstatistics #6975
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ void ps(void) | |
#endif | ||
"%-9sQ | pri " | ||
#ifdef DEVELHELP | ||
"| stack ( used) | base | current " | ||
"| stack ( used) | base | current " | ||
#endif | ||
#ifdef MODULE_SCHEDSTATISTICS | ||
"| runtime | switches" | ||
|
@@ -98,7 +98,8 @@ void ps(void) | |
overall_used += stacksz; | ||
#endif | ||
#ifdef MODULE_SCHEDSTATISTICS | ||
double runtime_ticks = sched_pidlist[i].runtime_ticks / (double) xtimer_now() * 100; | ||
double runtime_ticks = sched_pidlist[i].runtime_ticks / | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this only works for the first 2**32 ticks after boot, right? (Now that we're looking at it. :) ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And ... can we get change this to use uint64_t? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will look into it |
||
(double) _xtimer_now64() * 100; | ||
int switches = sched_pidlist[i].schedules; | ||
#endif | ||
printf("\t%3" PRIkernel_pid | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
APPLICATION = ps_schedstatistics | ||
include ../Makefile.tests_common | ||
|
||
BOARD_INSUFFICIENT_MEMORY := chronos msb-430 msb-430h nucleo-f030 nucleo-l053 \ | ||
nucleo32-f031 nucleo32-f042 nucleo32-l031 \ | ||
stm32f0discovery telosb weio wsn430-v1_3b \ | ||
wsn430-v1_4 z1 | ||
|
||
CFLAGS += -DDEVELHELP | ||
USEMODULE += shell | ||
USEMODULE += shell_commands | ||
USEMODULE += ps | ||
USEMODULE += schedstatistics | ||
USEMODULE += printf_float | ||
|
||
include $(RIOTBASE)/Makefile.include |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (C) 2017 OTA keys S.A. | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup tests | ||
* @{ | ||
* | ||
* @file | ||
* @brief ps schedstatistics test app | ||
* | ||
* @author Vincent Dupont <vincent@otakeys.com> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <inttypes.h> | ||
|
||
#include <shell.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For future reference: internal includes are marked with |
||
#include <thread.h> | ||
#include <xtimer.h> | ||
|
||
#define NB_THREADS 5 | ||
|
||
static char stacks[NB_THREADS][THREAD_STACKSIZE_DEFAULT]; | ||
static kernel_pid_t pids[NB_THREADS]; | ||
|
||
static void *_thread_fn(void *arg) | ||
{ | ||
int next = (int)arg < NB_THREADS - 1 ? (int)arg + 1 : 0; | ||
msg_t msg; | ||
|
||
printf("Creating thread #%d, next=%d\n", (int)arg, next); | ||
|
||
while (1) { | ||
msg_receive(&msg); | ||
xtimer_usleep(XTIMER_BACKOFF - 1); | ||
xtimer_usleep(2 * XTIMER_BACKOFF); | ||
msg_send(&msg, pids[next]); | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
int main(void) | ||
{ | ||
for (int i = 0; i < NB_THREADS; i++) { | ||
pids[i] = thread_create(stacks[i], sizeof(stacks[i]), | ||
THREAD_PRIORITY_MAIN + 1, | ||
THREAD_CREATE_STACKTEST, | ||
_thread_fn, (void *)i, "thread"); | ||
} | ||
|
||
|
||
msg_t msg; | ||
msg_send(&msg, pids[0]); | ||
|
||
char line_buf[SHELL_DEFAULT_BUFSIZE]; | ||
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint64_t would be more semantically correct since _xtimer_now64 returns an uint64_t