[PATCH 8/9] capture: Remove ctload command.

Jennifer Averett jennifer.averett at oarcorp.com
Tue Sep 30 14:13:27 UTC 2014


rtems_cpu_usage_top should be used for this information.
---
 cpukit/libmisc/capture/capture-cli.c | 272 -----------------------------------
 1 file changed, 272 deletions(-)

diff --git a/cpukit/libmisc/capture/capture-cli.c b/cpukit/libmisc/capture/capture-cli.c
index fb93e53..dc1f3bc 100644
--- a/cpukit/libmisc/capture/capture-cli.c
+++ b/cpukit/libmisc/capture/capture-cli.c
@@ -47,26 +47,11 @@
 static int                   rtems_capture_cli_task_count = 0;
 
 /*
- * Array of tasks sorted by load.
- */
-static rtems_tcb*            rtems_capture_cli_load_tasks[RTEMS_CAPTURE_CLI_MAX_LOAD_TASKS + 1];
-
-/*
- * The load for each tcb at the moment rtems_capture_cli_load_tasks was generated.
- */
-static unsigned long long    rtems_capture_cli_load[RTEMS_CAPTURE_CLI_MAX_LOAD_TASKS + 1];
-
-/*
  * The user capture timestamper.
  */
 static rtems_capture_timestamp capture_timestamp;
 
 /*
- * Common variable to sync the load monitor task.
- */
-static volatile int cli_load_thread_active;
-
-/*
  * rtems_capture_cli_open
  *
  *  DESCRIPTION:
@@ -375,255 +360,6 @@ rtems_capture_cli_task_list (int                                argc RC_UNUSED,
   rtems_iterate_over_all_threads (rtems_capture_cli_print_task);
 }
 
-static void
-rtems_capture_cli_task_sort (rtems_tcb* tcb)
-{
-  int                   i;
-  int                   j;
-
-  if (tcb)
-  {
-    rtems_capture_time_t l = tcb->cpu_time_used;
-
-    rtems_capture_cli_task_count++;
-
-    for (i = 0; i < RTEMS_CAPTURE_CLI_MAX_LOAD_TASKS; i++)
-    {
-      if (rtems_capture_cli_load_tasks[i])
-      {
-        if ((l == 0) || (l < rtems_capture_cli_load[i]))
-          continue;
-
-        for (j = (RTEMS_CAPTURE_CLI_MAX_LOAD_TASKS - 1); j >= i; j--)
-        {
-          rtems_capture_cli_load_tasks[j + 1] = rtems_capture_cli_load_tasks[j];
-          rtems_capture_cli_load[j + 1]  = rtems_capture_cli_load[j];
-        }
-      }
-
-      rtems_capture_cli_load_tasks[i] = tcb;
-      rtems_capture_cli_load[i]  = l;
-      break;
-    }
-  }
-}
-
-/*
- * rtems_capture_cli_task_load_thread
- *
- *  DESCRIPTION:
- *
- * This function displays the load of the tasks on an ANSI terminal.
- *
- */
-
-static void
-rtems_capture_cli_task_load_thread (rtems_task_argument arg)
-{
-  rtems_tcb*          tcb;
-  rtems_task_priority ceiling = rtems_capture_watch_get_ceiling ();
-  rtems_task_priority floor = rtems_capture_watch_get_floor ();
-  int                 last_count = 0;
-  FILE*               pstdout = (FILE*) arg;
-  int                 i;
-  int                 j;
-
-  fileno(stdout);
-  stdout = pstdout;
-
-  while (true)
-  {
-    Timestamp_Control  uptime, total, ran, uptime_at_last_reset;
-    uint32_t seconds, nanoseconds;
-    size_t                size;
-
-    cli_load_thread_active = 1;
-
-    /*
-     * Iterate over the tasks and sort the highest load tasks
-     * into our local arrays. We only handle a limited number of
-     * tasks.
-     */
-    size = sizeof (rtems_capture_cli_load_tasks); 
-    memset (rtems_capture_cli_load_tasks, 0, size);
-    memset (rtems_capture_cli_load, 0, sizeof (rtems_capture_cli_load));
-
-    _Timestamp_Set_to_zero( &total );
-    uptime_at_last_reset = CPU_usage_Uptime_at_last_reset;
-    _TOD_Get_uptime( &uptime );
-    seconds = _Timestamp_Get_seconds( &uptime );
-    nanoseconds = _Timestamp_Get_nanoseconds( &uptime ) /
-                  TOD_NANOSECONDS_PER_MICROSECOND;
-
-    rtems_iterate_over_all_threads (rtems_capture_cli_task_sort);
-
-    fprintf (stdout, "\x1b[H\x1b[J Press ENTER to exit.\n\n");
-    fprintf (stdout, "uptime: ");
-    fprintf (stdout, "%7" PRIu32 ".%06" PRIu32 "\n",  seconds, nanoseconds);
-    fprintf (stdout,
-             "\n\n"
-             "     PID NAME RPRI CPRI STATE      EXEC TIME   %%CPU\n");
-
-    if (rtems_capture_cli_task_count > last_count)
-      j = rtems_capture_cli_task_count;
-    else
-      j = last_count;
-
-    for (i = 0; i < RTEMS_CAPTURE_CLI_MAX_LOAD_TASKS; i++)
-    {
-      rtems_task_priority priority;
-      Timestamp_Control   last;
-      uint32_t            ival, fval;
- 
-      if (!rtems_capture_cli_load_tasks[i])
-        break;
-
-      j--;
-
-      /*
-       * If this is the currently executing thread, account for time
-       * since the last context switch.
-       */
-      tcb = rtems_capture_cli_load_tasks[i];
-      ran = rtems_capture_cli_load[i];
-      if ( _Thread_Get_time_of_last_context_switch( tcb, &last ) ) {
-        Timestamp_Control used;
-        _TOD_Get_uptime( &uptime );
-        _Timestamp_Subtract( &last, &uptime, &used );
-        _Timestamp_Add_to( &ran, &used );
-      } else {
-        _TOD_Get_uptime( &uptime );
-      }
-      _Timestamp_Subtract( &uptime_at_last_reset, &uptime, &total );
-      _Timestamp_Divide( &ran, &total, &ival, &fval );
-      seconds = _Timestamp_Get_seconds( &ran );
-      nanoseconds = _Timestamp_Get_nanoseconds( &ran ) /
-             TOD_NANOSECONDS_PER_MICROSECOND;
- 
-      priority = rtems_capture_task_real_priority (tcb);
-
-      fprintf (stdout, "\x1b[K");
-      rtems_monitor_dump_id (rtems_capture_task_id (tcb));
-      fprintf (stdout, " ");
-      rtems_monitor_dump_name (rtems_capture_task_id (tcb));
-      fprintf (stdout, "  ");
-      rtems_monitor_dump_priority (priority);
-      fprintf (stdout, "  ");
-      rtems_monitor_dump_priority (rtems_capture_task_curr_priority (tcb));
-      fprintf (stdout, " ");
-      rtems_monitor_dump_state (rtems_capture_task_state (tcb));
-      fprintf (stdout,
-            "%7" PRIu32 ".%06" PRIu32 " |%4" PRIu32 ".%03" PRIu32 ,
-            seconds, nanoseconds, ival, fval
-       );
-      fprintf (stdout, "    %c%c",
-              'a',
-              rtems_capture_task_flags (tcb) & RTEMS_CAPTURE_TRACED ? 't' : '-');
-
-      if ((floor > ceiling) && (ceiling > priority))
-        fprintf (stdout, "--");
-      else
-        fprintf (stdout, "%c%c",
-                rtems_capture_task_control (tcb) ?
-                (rtems_capture_task_control_flags (tcb) &
-                 RTEMS_CAPTURE_WATCH ? 'w' : '+') : '-',
-                rtems_capture_watch_global_on () ? 'g' : '-');
-
-      fprintf (stdout, "   ");
-      fprintf (stdout, "\n");
-    }
-
-    if (rtems_capture_cli_task_count < RTEMS_CAPTURE_CLI_MAX_LOAD_TASKS)
-    {
-      j = RTEMS_CAPTURE_CLI_MAX_LOAD_TASKS - rtems_capture_cli_task_count;
-      while (j > 0)
-      {
-        fprintf (stdout, "\x1b[K\n");
-        j--;
-      }
-    }
-
-    last_count = rtems_capture_cli_task_count;
-
-    cli_load_thread_active = 0;
-
-    rtems_task_wake_after (RTEMS_MICROSECONDS_TO_TICKS (5000000));
-  }
-}
-
-/*
- * rtems_capture_cli_task_load
- *
- *  DESCRIPTION:
- *
- * This function is a monitor command.
- *
- */
-
-static void
-rtems_capture_cli_task_load (int                                argc RC_UNUSED,
-                             char**                             argv RC_UNUSED,
-                             const rtems_monitor_command_arg_t* command_arg RC_UNUSED,
-                             bool                               verbose RC_UNUSED)
-{
-  rtems_status_code   sc;
-  rtems_task_priority priority;
-  rtems_name          name;
-  rtems_id            id;
-
-  sc = rtems_task_set_priority (RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
-
-  if (sc != RTEMS_SUCCESSFUL)
-  {
-    fprintf (stdout, "error: cannot obtain the current priority: %s\n",
-             rtems_status_text (sc));
-    return;
-  }
-
-  name = rtems_build_name('C', 'P', 'l', 't');
-
-  sc = rtems_task_create (name, priority, 4 * 1024,
-                          RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
-                          RTEMS_PREEMPT | RTEMS_TIMESLICE | RTEMS_NO_ASR,
-                          &id);
-
-  if (sc != RTEMS_SUCCESSFUL)
-  {
-    fprintf (stdout, "error: cannot create helper thread: %s\n",
-             rtems_status_text (sc));
-    return;
-  }
-
-  sc = rtems_task_start (id, rtems_capture_cli_task_load_thread, (intptr_t) stdout);
-
-  if (sc != RTEMS_SUCCESSFUL)
-  {
-    fprintf (stdout, "error: cannot start helper thread: %s\n",
-             rtems_status_text (sc));
-    rtems_task_delete (id);
-    return;
-  }
-
-  for (;;)
-  {
-    int c = getchar ();
-
-    if ((c == '\r') || (c == '\n'))
-    {
-      int loops = 20;
-
-      while (loops && cli_load_thread_active)
-        rtems_task_wake_after (RTEMS_MICROSECONDS_TO_TICKS (100000));
-
-      rtems_task_delete (id);
-
-      fprintf (stdout, "load monitoring stopped.\n");
-
-      return;
-    }
-  }
-}
-
 /*
  * rtems_capture_cli_watch_list
  *
@@ -1606,14 +1342,6 @@ static rtems_monitor_command_entry_t rtems_capture_cli_cmds[] =
     0
   },
   {
-    "ctload",
-    "usage: ctload \n",
-    0,
-    rtems_capture_cli_task_load,
-    { 0 },
-    0
-  },
-  {
     "cwlist",
     "usage: cwlist\n",
     0,
-- 
1.8.1.4



More information about the devel mailing list