From 92d8243153d752b004625b5bf633bedd1c64fe92 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 24 Nov 2018 17:56:23 -0600 Subject: [PATCH] apps/system/critmon: Fix some bugs found in initial testing. Stack size must be configurable to avoid issues with the simulator. --- system/critmon/Kconfig | 24 ++++++++++++++++++------ system/critmon/Makefile | 7 +++++-- system/critmon/critmon.c | 28 ++++++++++++++-------------- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/system/critmon/Kconfig b/system/critmon/Kconfig index 3961537d2..e88331b4c 100644 --- a/system/critmon/Kconfig +++ b/system/critmon/Kconfig @@ -16,23 +16,35 @@ menuconfig SYSTEM_CRITMONITOR if SYSTEM_CRITMONITOR config SYSTEM_CRITMONITOR_STACKSIZE - int "Stack monitor daemon stack size" + int "Critical section monitor stop/stop stack size" default 2048 ---help--- - The stack size to use the stack monitor daemon. Default: 2048 + The stack size to use the critmon_start/critmon_stop task. Default: 2048 config SYSTEM_CRITMONITOR_PRIORITY - int "Stack monitor daemon priority" + int "Critical section monitor stop/stop priority" + default 100 + ---help--- + The priority to use the critmon_start/critmon_stop task. Default: 100 + +config SYSTEM_CRITMONITOR_DAEMON_STACKSIZE + int "Critical section monitor daemon stack size" + default 2048 + ---help--- + The stack size to use the critical section monitor daemon. Default: 2048 + +config SYSTEM_CRITMONITOR_DAEMON_PRIORITY + int "Critical section monitor daemon priority" default 50 ---help--- The priority to use the stack monitor daemon. Default: 50 config SYSTEM_CRITMONITOR_INTERVAL - int "Stack monitor dump frequency" + int "Critical section monitor dump frequency" default 2 ---help--- - The rate in seconds that the stack monitor will wait before dumping - the next set stack usage information. Default: 2 seconds. + The rate in seconds that the Critical section monitor will wait before + dumping the next set Critical section information. Default: 2 seconds. config SYSTEM_CRITMONITOR_MOUNTPOINT string "procfs mountpoint" diff --git a/system/critmon/Makefile b/system/critmon/Makefile index 4eba214e6..c2d38a72a 100644 --- a/system/critmon/Makefile +++ b/system/critmon/Makefile @@ -37,8 +37,11 @@ # Stack Monitor Application -PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = 2048 +CONFIG_SYSTEM_CRITMONITOR_PRIORITY ?= 2048 +CONFIG_SYSTEM_CRITMONITOR_STACKSIZE ?= SCHED_DAEMON_PRIORITY_DEFAULT + +PRIORITY = $(CONFIG_SYSTEM_CRITMONITOR_PRIORITY) +STACKSIZE = $(CONFIG_SYSTEM_CRITMONITOR_STACKSIZE) MAINSRC = critmon.c diff --git a/system/critmon/critmon.c b/system/critmon/critmon.c index 1da8b6b46..5875bbe63 100644 --- a/system/critmon/critmon.c +++ b/system/critmon/critmon.c @@ -58,12 +58,12 @@ * Pre-processor Definitions ****************************************************************************/ -#ifndef CONFIG_SYSTEM_CRITMONITOR_STACKSIZE -# define CONFIG_SYSTEM_CRITMONITOR_STACKSIZE 2048 +#ifndef CONFIG_SYSTEM_CRITMONITOR_DAEMON_STACKSIZE +# define CONFIG_SYSTEM_CRITMONITOR_DAEMON_STACKSIZE 2048 #endif -#ifndef CONFIG_SYSTEM_CRITMONITOR_PRIORITY -# define CONFIG_SYSTEM_CRITMONITOR_PRIORITY 50 +#ifndef CONFIG_SYSTEM_CRITMONITOR_DAEMON_PRIORITY +# define CONFIG_SYSTEM_CRITMONITOR_DAEMON_PRIORITY 50 #endif #ifndef CONFIG_SYSTEM_CRITMONITOR_INTERVAL @@ -228,7 +228,7 @@ static int critmon_process_directory(FAR struct dirent *entryp) goto errout_with_filepath; } - /* Format: X.XXXXXXXXXXXX,X.XXXXXXXXX */ + /* Format: X.XXXXXXXXX,X.XXXXXXXXX */ maxpreemp = g_critmon.line; maxcrit = strchr(g_critmon.line, ','); @@ -249,8 +249,8 @@ static int critmon_process_directory(FAR struct dirent *entryp) #else printf("Thread ID %s:\n", entryp->d_name); #endif - printf(" Max Pre-emption Disable: %s%12s\n", maxpreemp); - printf(" Max Critical Section: %s%12s\n", maxcrit); + printf(" Max Pre-emption Disable: %s\n", maxpreemp); + printf(" Max Critical Section: %s\n", maxcrit); ret = OK; @@ -312,7 +312,7 @@ static void critmon_global_crit(void) filepath = NULL; - ret = asprintf(&filepath, CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "critmon"); + ret = asprintf(&filepath, CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/critmon"); if (ret < 0 || filepath == NULL) { errcode = errno; @@ -336,7 +336,7 @@ static void critmon_global_crit(void) while (fgets(g_critmon.line, 80, stream) != NULL) { - /* Format: X,X.XXXXXXXXXXXX,X.XXXXXXXXX */ + /* Format: X,X.XXXXXXXXX,X.XXXXXXXXX */ cpu = g_critmon.line; maxpreemp = strchr(g_critmon.line, ','); @@ -344,7 +344,7 @@ static void critmon_global_crit(void) if (maxpreemp != NULL) { *maxpreemp++ = '\0'; - maxcrit = strchr(g_critmon.line, ','); + maxcrit = strchr(maxpreemp, ','); if (maxcrit != NULL) { *maxcrit++ = '\0'; @@ -363,8 +363,8 @@ static void critmon_global_crit(void) /* Finally, output the stack info that we gleaned from the procfs */ printf("CPU %s:\n", cpu); - printf(" Max Pre-emption Disable: %s%12s\n", maxpreemp); - printf(" Max Critical Section: %s%12s\n", maxcrit); + printf(" Max Pre-emption Disable: %s\n", maxpreemp); + printf(" Max Critical Section: %s\n", maxcrit); } fclose(stream); @@ -488,8 +488,8 @@ int critmon_start_main(int argc, char **argv) g_critmon.started = true; g_critmon.stop = false; - ret = task_create("Csection Monitor", CONFIG_SYSTEM_CRITMONITOR_PRIORITY, - CONFIG_SYSTEM_CRITMONITOR_STACKSIZE, + ret = task_create("Csection Monitor", CONFIG_SYSTEM_CRITMONITOR_DAEMON_PRIORITY, + CONFIG_SYSTEM_CRITMONITOR_DAEMON_STACKSIZE, (main_t)critmon_daemon, (FAR char * const *)NULL); if (ret < 0) {