source: rtems/cpukit/libmisc/cpuuse/cpuusagereset.c @ 3380ee8

4.115
Last change on this file since 3380ee8 was 3380ee8, checked in by Sebastian Huber <sebastian.huber@…>, on 04/22/14 at 05:46:53

score: Use common names for per-CPU variables

Use "cpu" for an arbitrary Per_CPU_Control variable.

Use "cpu_self" for the Per_CPU_Control of the current processor.

Use "cpu_index" for an arbitrary processor index.

Use "cpu_index_self" for the processor index of the current processor.

Use "cpu_count" for the processor count obtained via
_SMP_Get_processor_count().

Use "cpu_max" for the processor maximum obtained by
rtems_configuration_get_maximum_processors().

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief CPU Usage Reset
5 * @ingroup libmisc_cpuuse CPU Usage
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2009
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/cpuuse.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/todimpl.h>
24#include <rtems/score/watchdogimpl.h>
25
26static void CPU_usage_Per_thread_handler(
27  Thread_Control *the_thread
28)
29{
30  #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
31    _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
32  #else
33    the_thread->cpu_time_used = 0;
34  #endif
35}
36
37/*
38 *  rtems_cpu_usage_reset
39 */
40void rtems_cpu_usage_reset( void )
41{
42  #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
43    uint32_t cpu_count;
44    uint32_t cpu_index;
45
46    _TOD_Get_uptime( &CPU_usage_Uptime_at_last_reset );
47
48    cpu_count = rtems_get_processor_count();
49    for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
50      Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
51
52      cpu->time_of_last_context_switch = CPU_usage_Uptime_at_last_reset;
53    }
54  #else
55    CPU_usage_Ticks_at_last_reset = _Watchdog_Ticks_since_boot;
56  #endif
57
58  rtems_iterate_over_all_threads(CPU_usage_Per_thread_handler);
59}
Note: See TracBrowser for help on using the repository browser.