source: rtems/cpukit/libmisc/cpuuse/cpuusagereset.c

Last change on this file was cfe8f7a, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 27, 2020 at 2:14:06 PM

doxygen: Switch @brief and @ingroup

This order change fixes the Latex documentation build via Doxygen.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup libmisc_cpuuse CPU Usage
5 *
6 * @brief CPU Usage Reset
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2009
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifdef HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/cpuuse.h>
23#include <rtems/score/percpu.h>
24#include <rtems/score/todimpl.h>
25#include <rtems/score/schedulerimpl.h>
26#include <rtems/score/watchdogimpl.h>
27
28#include "cpuuseimpl.h"
29
30static bool CPU_usage_Per_thread_handler(
31  Thread_Control *the_thread,
32  void           *arg
33)
34{
35  const Scheduler_Control *scheduler;
36  ISR_lock_Context         state_lock_context;
37  ISR_lock_Context         scheduler_lock_context;
38
39  _Thread_State_acquire( the_thread, &state_lock_context );
40  scheduler = _Thread_Scheduler_get_home( the_thread );
41  _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
42
43  _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
44
45  _Scheduler_Release_critical( scheduler, &scheduler_lock_context );
46  _Thread_State_release( the_thread, &state_lock_context );
47  return false;
48}
49
50/*
51 *  rtems_cpu_usage_reset
52 */
53void rtems_cpu_usage_reset( void )
54{
55  uint32_t cpu_count;
56  uint32_t cpu_index;
57
58  _TOD_Get_uptime( &CPU_usage_Uptime_at_last_reset );
59
60  cpu_count = rtems_scheduler_get_processor_maximum();
61  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
62    Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
63
64    cpu->cpu_usage_timestamp = CPU_usage_Uptime_at_last_reset;
65  }
66
67  rtems_task_iterate(CPU_usage_Per_thread_handler, NULL);
68}
Note: See TracBrowser for help on using the repository browser.