mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
core: only store the stack size for DEVELHELP
`tcp_t::stack_size` is only examined by the shell command `ps` and `DEBUG_PRINT`. For the latter one only if `DEVELHELP` was enabled. This PR guards the member `tcp_t::stack_size` in `#ifdef DEVELHELP`. Only if DEVELHELP was activated its value get printed by `ps`. Closes #1287.
This commit is contained in:
parent
5886d83333
commit
9e3830a72b
@ -72,7 +72,10 @@ typedef struct tcb_t {
|
||||
|
||||
const char *name; /**< thread's name */
|
||||
char *stack_start; /**< thread's stack start address */
|
||||
|
||||
#ifdef DEVELHELP
|
||||
int stack_size; /**< thread's stack size */
|
||||
#endif
|
||||
} tcb_t;
|
||||
|
||||
#endif /* TCB_H_ */
|
||||
|
@ -109,7 +109,9 @@ int thread_measure_stack_free(char *stack)
|
||||
kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags, void *(*function)(void *arg), void *arg, const char *name)
|
||||
{
|
||||
/* allocate our thread control block at the top of our stackspace */
|
||||
#ifdef DEVELHELP
|
||||
int total_stacksize = stacksize;
|
||||
#endif
|
||||
stacksize -= sizeof(tcb_t);
|
||||
|
||||
/* align tcb address on 32bit boundary */
|
||||
@ -174,7 +176,10 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags,
|
||||
|
||||
cb->sp = thread_stack_init(function, arg, stack, stacksize);
|
||||
cb->stack_start = stack;
|
||||
|
||||
#ifdef DEVELHELP
|
||||
cb->stack_size = total_stacksize;
|
||||
#endif
|
||||
|
||||
cb->priority = priority;
|
||||
cb->status = 0;
|
||||
|
40
sys/ps/ps.c
40
sys/ps/ps.c
@ -41,9 +41,15 @@ void thread_print_all(void)
|
||||
{
|
||||
const char queued_name[] = {'_', 'Q'};
|
||||
int i;
|
||||
int overall_stacksz = 0;
|
||||
#ifdef DEVELHELP
|
||||
int overall_stacksz = 0, overall_used = 0;
|
||||
#endif
|
||||
|
||||
printf("\tpid | %-21s| %-9sQ | pri | stack ( used) location"
|
||||
printf("\tpid | %-21s| %-9sQ | pri | "
|
||||
#ifdef DEVELHELP
|
||||
"stack ( used) "
|
||||
#endif
|
||||
"location"
|
||||
#if SCHEDSTATISTICS
|
||||
" | runtime | switches"
|
||||
#endif
|
||||
@ -57,19 +63,30 @@ void thread_print_all(void)
|
||||
int state = p->status; /* copy state */
|
||||
const char *sname = state_names[state]; /* get state name */
|
||||
const char *queued = &queued_name[(int)(state >= STATUS_ON_RUNQUEUE)]; /* get queued flag */
|
||||
#ifdef DEVELHELP
|
||||
int stacksz = p->stack_size; /* get stack size */
|
||||
#if SCHEDSTATISTICS
|
||||
int runtime_ticks = sched_pidlist[i].runtime_ticks / (hwtimer_now()/1000UL + 1);
|
||||
int switches = sched_pidlist[i].schedules;
|
||||
#endif
|
||||
overall_stacksz += stacksz;
|
||||
stacksz -= thread_measure_stack_free(p->stack_start);
|
||||
printf("\t%3" PRIkernel_pid " | %-21s| %-8s %.1s | %3i | %5i (%5i) %p"
|
||||
overall_used += stacksz;
|
||||
#endif
|
||||
#if SCHEDSTATISTICS
|
||||
" | %4d/1k | %8d"
|
||||
double runtime_ticks = sched_pidlist[i].runtime_ticks / (double) hwtimer_now() * 100;
|
||||
int switches = sched_pidlist[i].schedules;
|
||||
#endif
|
||||
printf("\t%3u | %-21s| %-8s %.1s | %3i | "
|
||||
#ifdef DEVELHELP
|
||||
"%5i (%5i) "
|
||||
#endif
|
||||
"%p"
|
||||
#if SCHEDSTATISTICS
|
||||
" | %6.3f%% | %8d"
|
||||
#endif
|
||||
"\n",
|
||||
p->pid, p->name, sname, queued, p->priority, p->stack_size, stacksz, p->stack_start
|
||||
p->pid, p->name, sname, queued, p->priority,
|
||||
#ifdef DEVELHELP
|
||||
p->stack_size, stacksz,
|
||||
#endif
|
||||
p->stack_start
|
||||
#if SCHEDSTATISTICS
|
||||
, runtime_ticks, switches
|
||||
#endif
|
||||
@ -77,5 +94,8 @@ void thread_print_all(void)
|
||||
}
|
||||
}
|
||||
|
||||
printf("\t%5s %-21s|%13s%6s %5i\n", "|", "SUM", "|", "|", overall_stacksz);
|
||||
#ifdef DEVELHELP
|
||||
printf("\t%5s %-21s|%13s%6s %5i (%5i)\n", "|", "SUM", "|", "|",
|
||||
overall_stacksz, overall_used);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user