You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/06/14 14:52:21 UTC

[GitHub] [incubator-nuttx-apps] xiaoxiang781216 opened a new pull request #769: system/critmon: add critmon program for critmon once

xiaoxiang781216 opened a new pull request #769:
URL: https://github.com/apache/incubator-nuttx-apps/pull/769


   ## Summary
   
   ## Impact
   Add new command(critmon)
   
   ## Testing
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx-apps] davids5 commented on a change in pull request #769: system/critmon: add critmon program for critmon once

Posted by GitBox <gi...@apache.org>.
davids5 commented on a change in pull request #769:
URL: https://github.com/apache/incubator-nuttx-apps/pull/769#discussion_r654792961



##########
File path: system/critmon/critmon.c
##########
@@ -378,101 +378,115 @@ static void critmon_global_crit(void)
 }
 
 /****************************************************************************
- * Name: critmon_daemon
+ * Name: critmon_list_once
  ****************************************************************************/
 
-static int critmon_daemon(int argc, char **argv)
+static int critmon_list_once(void)
 {
-  DIR *dirp;
   int exitcode = EXIT_SUCCESS;
   int errcount = 0;
+  DIR *dirp;
   int ret;
 
-  printf("Csection Monitor: Running: %d\n", g_critmon.pid);
-
-  /* Loop until we detect that there is a request to stop. */
-
-  while (!g_critmon.stop)
-    {
-      /* Wait for the next sample interval */
-
-      sleep(CONFIG_SYSTEM_CRITMONITOR_INTERVAL);
-
-      /* Output a Header */
+  /* Output a Header */
 
 #if CONFIG_TASK_NAME_SIZE > 0
-      printf("PRE-EMPTION CSECTION    PID   DESCRIPTION\n");
+  printf("PRE-EMPTION CSECTION    PID   DESCRIPTION\n");
 #else
-      printf("PRE-EMPTION CSECTION    PID\n");
+  printf("PRE-EMPTION CSECTION    PID\n");
 #endif
-      printf("MAX DISABLE MAX TIME\n");
+  printf("MAX DISABLE MAX TIME\n");
 
-      /* Should global usage first */
+  /* Should global usage first */
 
-      critmon_global_crit();
+  critmon_global_crit();
 
-      /* Open the top-level procfs directory */
+  /* Open the top-level procfs directory */
 
-      dirp = opendir(CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT);
-      if (dirp == NULL)
-        {
-          /* Failed to open the directory */
+  dirp = opendir(CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT);
+  if (dirp == NULL)
+    {
+      /* Failed to open the directory */
 
-          fprintf(stderr, "Csection Monitor: Failed to open directory: %s\n",
-                  CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT);
+      fprintf(stderr, "Csection Monitor: Failed to open directory: %s\n",
+              CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT);
 
-          if (++errcount > 100)
-            {
-              fprintf(stderr,
-                      "Csection Monitor: Too many errors ... exiting\n");
-              exitcode = EXIT_FAILURE;
-              break;
-            }
+      if (++errcount > 100)
+        {
+          fprintf(stderr, "Csection Monitor: Too many errors ... exiting\n");
+          return EXIT_FAILURE;
         }
+    }
 
-      /* Read each directory entry */
+  /* Read each directory entry */
 
-      for (; ; )
+  for (; ; )
+    {
+      FAR struct dirent *entryp = readdir(dirp);
+      if (entryp == NULL)
         {
-          FAR struct dirent *entryp = readdir(dirp);
-          if (entryp == NULL)
-            {
-              /* Finished with this directory */
+          /* Finished with this directory */
 
-              break;
-            }
+          break;
+        }
 
-          /* Task/thread entries in the /proc directory will all be (1)
-           * directories with (2) all numeric names.
-           */
+      /* Task/thread entries in the /proc directory will all be (1)
+       * directories with (2) all numeric names.
+       */
 
-          if (DIRENT_ISDIRECTORY(entryp->d_type) &&
-              critmon_check_name(entryp->d_name))
+      if (DIRENT_ISDIRECTORY(entryp->d_type) &&
+          critmon_check_name(entryp->d_name))
+        {
+          /* Looks good -- process the directory */
+
+          ret = critmon_process_directory(entryp);
+          if (ret < 0)
             {
-              /* Looks good -- process the directory */
+              /* Failed to process the thread directory */
 
-              ret = critmon_process_directory(entryp);
-              if (ret < 0)
-                {
-                  /* Failed to process the thread directory */
+              fprintf(stderr, "Csection Monitor: "
+                      "Failed to process sub-directory: %s\n",
+                      entryp->d_name);
 
+              if (++errcount > 100)
+                {
                   fprintf(stderr, "Csection Monitor: "
-                          "Failed to process sub-directory: %s\n",
-                          entryp->d_name);
-
-                  if (++errcount > 100)
-                    {
-                      fprintf(stderr, "Csection Monitor: "
-                              "Too many errors ... exiting\n");
-                      exitcode = EXIT_FAILURE;
-                      break;
-                    }
+                          "Too many errors ... exiting\n");
+                  exitcode = EXIT_FAILURE;
+                  break;
                 }
             }
         }
+    }
+
+  closedir(dirp);
+  fputc('\n', stdout);
+  return exitcode;
+}
+
+/****************************************************************************
+ * Name: critmon_daemon
+ ****************************************************************************/
+
+static int critmon_daemon(int argc, char **argv)
+{
+  int exitcode = EXIT_SUCCESS;
+
+  printf("Csection Monitor: Running: %d\n", g_critmon.pid);
+
+  /* Loop until we detect that there is a request to stop. */
+
+  while (!g_critmon.stop)
+    {
+      /* Wait for the next sample interval */
 
-      closedir(dirp);
-      fputc('\n', stdout);
+      sleep(CONFIG_SYSTEM_CRITMONITOR_INTERVAL);

Review comment:
       Should this move to under the exit check so the user gets more immediate feedback?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx-apps] davids5 merged pull request #769: system/critmon: add critmon program for critmon once

Posted by GitBox <gi...@apache.org>.
davids5 merged pull request #769:
URL: https://github.com/apache/incubator-nuttx-apps/pull/769


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on a change in pull request #769: system/critmon: add critmon program for critmon once

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #769:
URL: https://github.com/apache/incubator-nuttx-apps/pull/769#discussion_r654809685



##########
File path: system/critmon/critmon.c
##########
@@ -378,101 +378,115 @@ static void critmon_global_crit(void)
 }
 
 /****************************************************************************
- * Name: critmon_daemon
+ * Name: critmon_list_once
  ****************************************************************************/
 
-static int critmon_daemon(int argc, char **argv)
+static int critmon_list_once(void)
 {
-  DIR *dirp;
   int exitcode = EXIT_SUCCESS;
   int errcount = 0;
+  DIR *dirp;
   int ret;
 
-  printf("Csection Monitor: Running: %d\n", g_critmon.pid);
-
-  /* Loop until we detect that there is a request to stop. */
-
-  while (!g_critmon.stop)
-    {
-      /* Wait for the next sample interval */
-
-      sleep(CONFIG_SYSTEM_CRITMONITOR_INTERVAL);
-
-      /* Output a Header */
+  /* Output a Header */
 
 #if CONFIG_TASK_NAME_SIZE > 0
-      printf("PRE-EMPTION CSECTION    PID   DESCRIPTION\n");
+  printf("PRE-EMPTION CSECTION    PID   DESCRIPTION\n");
 #else
-      printf("PRE-EMPTION CSECTION    PID\n");
+  printf("PRE-EMPTION CSECTION    PID\n");
 #endif
-      printf("MAX DISABLE MAX TIME\n");
+  printf("MAX DISABLE MAX TIME\n");
 
-      /* Should global usage first */
+  /* Should global usage first */
 
-      critmon_global_crit();
+  critmon_global_crit();
 
-      /* Open the top-level procfs directory */
+  /* Open the top-level procfs directory */
 
-      dirp = opendir(CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT);
-      if (dirp == NULL)
-        {
-          /* Failed to open the directory */
+  dirp = opendir(CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT);
+  if (dirp == NULL)
+    {
+      /* Failed to open the directory */
 
-          fprintf(stderr, "Csection Monitor: Failed to open directory: %s\n",
-                  CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT);
+      fprintf(stderr, "Csection Monitor: Failed to open directory: %s\n",
+              CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT);
 
-          if (++errcount > 100)
-            {
-              fprintf(stderr,
-                      "Csection Monitor: Too many errors ... exiting\n");
-              exitcode = EXIT_FAILURE;
-              break;
-            }
+      if (++errcount > 100)
+        {
+          fprintf(stderr, "Csection Monitor: Too many errors ... exiting\n");
+          return EXIT_FAILURE;
         }
+    }
 
-      /* Read each directory entry */
+  /* Read each directory entry */
 
-      for (; ; )
+  for (; ; )
+    {
+      FAR struct dirent *entryp = readdir(dirp);
+      if (entryp == NULL)
         {
-          FAR struct dirent *entryp = readdir(dirp);
-          if (entryp == NULL)
-            {
-              /* Finished with this directory */
+          /* Finished with this directory */
 
-              break;
-            }
+          break;
+        }
 
-          /* Task/thread entries in the /proc directory will all be (1)
-           * directories with (2) all numeric names.
-           */
+      /* Task/thread entries in the /proc directory will all be (1)
+       * directories with (2) all numeric names.
+       */
 
-          if (DIRENT_ISDIRECTORY(entryp->d_type) &&
-              critmon_check_name(entryp->d_name))
+      if (DIRENT_ISDIRECTORY(entryp->d_type) &&
+          critmon_check_name(entryp->d_name))
+        {
+          /* Looks good -- process the directory */
+
+          ret = critmon_process_directory(entryp);
+          if (ret < 0)
             {
-              /* Looks good -- process the directory */
+              /* Failed to process the thread directory */
 
-              ret = critmon_process_directory(entryp);
-              if (ret < 0)
-                {
-                  /* Failed to process the thread directory */
+              fprintf(stderr, "Csection Monitor: "
+                      "Failed to process sub-directory: %s\n",
+                      entryp->d_name);
 
+              if (++errcount > 100)
+                {
                   fprintf(stderr, "Csection Monitor: "
-                          "Failed to process sub-directory: %s\n",
-                          entryp->d_name);
-
-                  if (++errcount > 100)
-                    {
-                      fprintf(stderr, "Csection Monitor: "
-                              "Too many errors ... exiting\n");
-                      exitcode = EXIT_FAILURE;
-                      break;
-                    }
+                          "Too many errors ... exiting\n");
+                  exitcode = EXIT_FAILURE;
+                  break;
                 }
             }
         }
+    }
+
+  closedir(dirp);
+  fputc('\n', stdout);
+  return exitcode;
+}
+
+/****************************************************************************
+ * Name: critmon_daemon
+ ****************************************************************************/
+
+static int critmon_daemon(int argc, char **argv)
+{
+  int exitcode = EXIT_SUCCESS;
+
+  printf("Csection Monitor: Running: %d\n", g_critmon.pid);
+
+  /* Loop until we detect that there is a request to stop. */
+
+  while (!g_critmon.stop)
+    {
+      /* Wait for the next sample interval */
 
-      closedir(dirp);
-      fputc('\n', stdout);
+      sleep(CONFIG_SYSTEM_CRITMONITOR_INTERVAL);

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org