Changeset 9f9c0bb in rtems


Ignore:
Timestamp:
Dec 24, 2013, 5:42:23 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.11, master
Children:
6a26e9b
Parents:
2d1bdc8
git-author:
Chris Johns <chrisj@…> (12/24/13 05:42:23)
git-committer:
Chris Johns <chrisj@…> (12/24/13 05:46:19)
Message:

cpukit/capture: Use the new RTEMS API to get the uptime in nanoseconds.

Use the new API to get the uptime in nanoseconds and update the capture
engine.

Location:
cpukit/libmisc/capture
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/capture/capture-cli.c

    r2d1bdc8 r9f9c0bb  
    210210
    211211/*
     212 * rtems_catpure_cli_print_uptime
     213 *
     214 *  DESCRIPTION:
     215 *
     216 * This function prints the nanosecond uptime to stdout.
     217 */
     218static void
     219rtems_capture_cli_print_timestamp (uint64_t uptime)
     220{
     221  uint32_t hours;
     222  uint32_t minutes;
     223  uint32_t seconds;
     224  uint32_t usecs;
     225
     226  seconds = uptime / 1000000000LLU;
     227  minutes = seconds / 60;
     228  hours   = minutes / 60;
     229  minutes = minutes % 60;
     230  seconds = seconds % 60;
     231  usecs = (uptime / 1000) % 1000000;
     232
     233  fprintf (stdout, "%5lu:%02lu:%02lu.%06lu", hours, minutes, seconds, usecs);
     234}
     235
     236/*
    212237 * rtems_capture_cli_task_list
    213238 *
     
    227252  rtems_task_priority   floor = rtems_capture_watch_get_floor ();
    228253  rtems_capture_task_t* task = rtems_capture_get_task_list ();
    229   rtems_capture_time_t  total_time;
    230254  int                   count = rtems_capture_task_count ();
    231 
    232   rtems_capture_time (&total_time);
    233 
    234   fprintf (stdout, "total %i time:%Lu\n", count, (uint64_t) total_time);
     255  rtems_capture_time_t  uptime;
     256
     257  rtems_capture_time (&uptime);
     258
     259  fprintf (stdout, "uptime: ");
     260  rtems_capture_cli_print_timestamp (uptime);
     261  fprintf (stdout, "\ntotal %i\n", count);
    235262
    236263  while (task)
     
    248275      stack_used = 100;
    249276
    250     time_used = (rtems_capture_task_time (task) * 100) / total_time;
     277    time_used = (rtems_capture_task_time (task) * 100) / uptime;
    251278
    252279    if (time_used > 100)
     
    282309               rtems_capture_watch_global_on () ? 'g' : '-');
    283310    }
    284     fprintf (stdout, " %3" PRId32 "%% %3" PRId32 "%% (%" PRIu64 ")\n",
    285             stack_used, time_used, rtems_capture_task_time (task));
     311    fprintf (stdout, " %3" PRId32 "%% %3" PRId32 "%% ", stack_used, time_used);
     312    rtems_capture_cli_print_timestamp (rtems_capture_task_time (task));
     313    fprintf (stdout, "\n");
    286314
    287315    task = rtems_capture_next_task (task);
     
    299327
    300328static void
    301 rtems_capture_cli_task_load_thread (rtems_task_argument arg RC_UNUSED)
     329rtems_capture_cli_task_load_thread (rtems_task_argument arg)
    302330{
    303331  rtems_task_priority ceiling = rtems_capture_watch_get_ceiling ();
    304332  rtems_task_priority floor = rtems_capture_watch_get_floor ();
    305333  int                 last_count = 0;
    306 
    307   for (;;)
     334  FILE*               pstdout = (FILE*) arg;
     335
     336  fileno(stdout);
     337  stdout = pstdout;
     338
     339  while (true)
    308340  {
    309341    rtems_capture_task_t* tasks[RTEMS_CAPTURE_CLI_MAX_LOAD_TASKS + 1];
    310342    unsigned long long    load[RTEMS_CAPTURE_CLI_MAX_LOAD_TASKS + 1];
    311343    rtems_capture_task_t* task;
     344    rtems_capture_time_t  uptime;
    312345    rtems_capture_time_t  total_time;
    313346    int                   count = 0;
    314347    int                   i;
    315348    int                   j;
     349
     350    rtems_capture_time (&uptime);
    316351
    317352    cli_load_thread_active = 1;
     
    363398
    364399    fprintf (stdout, "\x1b[H\x1b[J Press ENTER to exit.\n\n");
     400    fprintf (stdout, "uptime: ");
     401    rtems_capture_cli_print_timestamp (uptime);
    365402    fprintf (stdout,
     403             "\n\n"
    366404             "     PID NAME RPRI CPRI STATE          %%CPU     %%STK FLGS    EXEC TIME\n");
    367405
     
    419457                rtems_capture_watch_global_on () ? 'g' : '-');
    420458
    421       fprintf (stdout, "   %qi\n",
    422                rtems_capture_task_time (tasks[i]));
     459      fprintf (stdout, "   ");
     460      rtems_capture_cli_print_timestamp (rtems_capture_task_time (tasks[i]));
     461      fprintf (stdout, "\n");
    423462    }
    424463
     
    484523  }
    485524
    486   sc = rtems_task_start (id, rtems_capture_cli_task_load_thread, 0);
     525  sc = rtems_task_start (id, rtems_capture_cli_task_load_thread, (intptr_t) stdout);
    487526
    488527  if (sc != RTEMS_SUCCESSFUL)
     
    13941433          if (event & 1)
    13951434          {
    1396             fprintf (stdout, "%9li.%06li ",
     1435            fprintf (stdout, "%12Lu %9lu.%09lu ",
     1436                     t,
    13971437                     (unsigned long) (t / 1000000000ULL),
    1398                      (unsigned long) (t % 1000000000ULL));
     1438                     (unsigned long) (t % 10000000000ULL));
    13991439            rtems_monitor_dump_id (rtems_capture_task_id (rec->task));
    14001440            fprintf (stdout, " %c%c%c%c",
  • cpukit/libmisc/capture/capture.c

    r2d1bdc8 r9f9c0bb  
    122122  else
    123123  {
    124     _TOD_Get_uptime(time);
     124    *time = rtems_clock_get_uptime_nanoseconds ();
    125125  }
    126126}
     
    954954    {
    955955      ct->out++;
    956       ct->time += time - ct->time_in;
     956      if (ct->time_in)
     957        ct->time += time - ct->time_in;
    957958    }
    958959
  • cpukit/libmisc/capture/capture.h

    r2d1bdc8 r9f9c0bb  
    5252 * A capture timestamp.
    5353 */
    54 typedef Timestamp_Control rtems_capture_time_t;
     54typedef uint64_t rtems_capture_time_t;
    5555
    5656/**
Note: See TracChangeset for help on using the changeset viewer.