source: rtems/cpukit/libmisc/cpuuse/cpuusagereset.c @ 0b416759

5
Last change on this file since 0b416759 was f9219db, checked in by Sebastian Huber <sebastian.huber@…>, on 04/05/19 at 06:16:05

rtems: Add rtems_scheduler_get_processor_maximum()

Add rtems_scheduler_get_processor_maximum() as a replacement for
rtems_get_processor_count(). The rtems_get_processor_count() is a bit
orphaned. Adopt it by the Scheduler Manager. The count is also
misleading, since the processor set may have gaps and the actual count
of online processors may be less than the value returned by
rtems_get_processor_count().

Update #3732.

  • Property mode set to 100644
File size: 1.6 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/percpu.h>
23#include <rtems/score/todimpl.h>
24#include <rtems/score/schedulerimpl.h>
25#include <rtems/score/watchdogimpl.h>
26
27#include "cpuuseimpl.h"
28
29static bool CPU_usage_Per_thread_handler(
30  Thread_Control *the_thread,
31  void           *arg
32)
33{
34  const Scheduler_Control *scheduler;
35  ISR_lock_Context         state_lock_context;
36  ISR_lock_Context         scheduler_lock_context;
37
38  _Thread_State_acquire( the_thread, &state_lock_context );
39  scheduler = _Thread_Scheduler_get_home( the_thread );
40  _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
41
42  _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
43
44  _Scheduler_Release_critical( scheduler, &scheduler_lock_context );
45  _Thread_State_release( the_thread, &state_lock_context );
46  return false;
47}
48
49/*
50 *  rtems_cpu_usage_reset
51 */
52void rtems_cpu_usage_reset( void )
53{
54  uint32_t cpu_count;
55  uint32_t cpu_index;
56
57  _TOD_Get_uptime( &CPU_usage_Uptime_at_last_reset );
58
59  cpu_count = rtems_scheduler_get_processor_maximum();
60  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
61    Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
62
63    cpu->cpu_usage_timestamp = CPU_usage_Uptime_at_last_reset;
64  }
65
66  rtems_task_iterate(CPU_usage_Per_thread_handler, NULL);
67}
Note: See TracBrowser for help on using the repository browser.