diff options
-rw-r--r-- | apps/system/stackmonitor/Makefile | 2 | ||||
-rw-r--r-- | apps/system/stackmonitor/stackmonitor.c | 21 | ||||
-rw-r--r-- | nuttx/sched/sched_foreach.c | 2 |
3 files changed, 23 insertions, 2 deletions
diff --git a/apps/system/stackmonitor/Makefile b/apps/system/stackmonitor/Makefile index 60bb7da03..e38935d32 100644 --- a/apps/system/stackmonitor/Makefile +++ b/apps/system/stackmonitor/Makefile @@ -41,7 +41,7 @@ ifeq ($(WINTOOL),y) INCDIROPT = -w endif -# USB Monitor Application +# Stack Monitor Application PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 768 diff --git a/apps/system/stackmonitor/stackmonitor.c b/apps/system/stackmonitor/stackmonitor.c index 98039828c..653a2fdc4 100644 --- a/apps/system/stackmonitor/stackmonitor.c +++ b/apps/system/stackmonitor/stackmonitor.c @@ -91,6 +91,21 @@ static struct stkmon_state_s g_stackmonitor; * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: stkmon_task + ****************************************************************************/ + +static void stkmon_task(FAR struct tcb_s *tcb, FAR void *arg) +{ +#if CONFIG_NAME_MAX > 0 + syslog("%5d %6d %6d %s\n", + tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb), tcb->name); +#else + syslog("%5d %6d %6d\n", + tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb)); +#endif +} + static int stackmonitor_daemon(int argc, char **argv) { syslog(STKMON_PREFIX "Running: %d\n", g_stackmonitor.pid); @@ -100,6 +115,12 @@ static int stackmonitor_daemon(int argc, char **argv) while (!g_stackmonitor.stop) { sleep(CONFIG_SYSTEM_STACKMONITOR_INTERVAL); +#if CONFIG_NAME_MAX > 0 + syslog("%-5s %-6s %-6s %s\n", "PID", "SIZE", "USED", "THREAD NAME"); +#else + syslog("%-5s %-6s %-6s\n", "PID", "SIZE", "USED"); +#endif + sched_foreach(stkmon_task, NULL); } /* Stopped */ diff --git a/nuttx/sched/sched_foreach.c b/nuttx/sched/sched_foreach.c index 192094533..e2e079889 100644 --- a/nuttx/sched/sched_foreach.c +++ b/nuttx/sched/sched_foreach.c @@ -68,7 +68,7 @@ void sched_foreach(sched_foreach_t handler, FAR void *arg) irqstate_t flags = irqsave(); int ndx; - /* Verify that the PID is within range */ + /* Vist each active task */ for (ndx = 0; ndx < CONFIG_MAX_TASKS; ndx++) { |