source: rtems/cpukit/include/rtems/score/profiling.h @ 4c20da4b

5
Last change on this file since 4c20da4b was 4c20da4b, checked in by Sebastian Huber <sebastian.huber@…>, on 04/04/19 at 07:18:11

doxygen: Rename Score* groups in RTEMSScore*

Update #3706

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSScoreProfiling
5 *
6 * @brief Profiling Support API
7 */
8
9/*
10 * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#ifndef _RTEMS_SCORE_PROFILING
24#define _RTEMS_SCORE_PROFILING
25
26#include <rtems/score/percpu.h>
27#include <rtems/score/isrlock.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif /* __cplusplus */
32
33/**
34 * @defgroup RTEMSScoreProfiling Profiling Support
35 *
36 * @ingroup RTEMSScore
37 *
38 * @brief Profiling support.
39 *
40 * @{
41 */
42
43static inline void _Profiling_Thread_dispatch_disable(
44  Per_CPU_Control *cpu,
45  uint32_t previous_thread_dispatch_disable_level
46)
47{
48#if defined( RTEMS_PROFILING )
49  if ( previous_thread_dispatch_disable_level == 0 ) {
50    Per_CPU_Stats *stats = &cpu->Stats;
51
52    stats->thread_dispatch_disabled_instant = _CPU_Counter_read();
53    ++stats->thread_dispatch_disabled_count;
54  }
55#else
56  (void) cpu;
57  (void) previous_thread_dispatch_disable_level;
58#endif
59}
60
61static inline void _Profiling_Thread_dispatch_disable_critical(
62  Per_CPU_Control        *cpu,
63  uint32_t                previous_thread_dispatch_disable_level,
64  const ISR_lock_Context *lock_context
65)
66{
67#if defined( RTEMS_PROFILING )
68  if ( previous_thread_dispatch_disable_level == 0 ) {
69    Per_CPU_Stats *stats = &cpu->Stats;
70
71    stats->thread_dispatch_disabled_instant = lock_context->ISR_disable_instant;
72    ++stats->thread_dispatch_disabled_count;
73  }
74#else
75  (void) cpu;
76  (void) previous_thread_dispatch_disable_level;
77  (void) lock_context;
78#endif
79}
80
81static inline void _Profiling_Thread_dispatch_enable(
82  Per_CPU_Control *cpu,
83  uint32_t new_thread_dispatch_disable_level
84)
85{
86#if defined( RTEMS_PROFILING )
87  if ( new_thread_dispatch_disable_level == 0 ) {
88    Per_CPU_Stats *stats = &cpu->Stats;
89    CPU_Counter_ticks now = _CPU_Counter_read();
90    CPU_Counter_ticks delta = _CPU_Counter_difference(
91      now,
92      stats->thread_dispatch_disabled_instant
93    );
94
95    stats->total_thread_dispatch_disabled_time += delta;
96
97    if ( stats->max_thread_dispatch_disabled_time < delta ) {
98      stats->max_thread_dispatch_disabled_time = delta;
99    }
100  }
101#else
102  (void) cpu;
103  (void) new_thread_dispatch_disable_level;
104#endif
105}
106
107static inline void _Profiling_Update_max_interrupt_delay(
108  Per_CPU_Control *cpu,
109  CPU_Counter_ticks interrupt_delay
110)
111{
112#if defined( RTEMS_PROFILING )
113  Per_CPU_Stats *stats = &cpu->Stats;
114
115  if ( stats->max_interrupt_delay < interrupt_delay ) {
116    stats->max_interrupt_delay = interrupt_delay;
117  }
118#else
119  (void) cpu;
120  (void) interrupt_delay;
121#endif
122}
123
124/**
125 * @brief Updates the interrupt profiling statistics.
126 *
127 * Must be called with the interrupt stack and before the thread dispatch
128 * disable level is decremented.
129 */
130void _Profiling_Outer_most_interrupt_entry_and_exit(
131  Per_CPU_Control *cpu,
132  CPU_Counter_ticks interrupt_entry_instant,
133  CPU_Counter_ticks interrupt_exit_instant
134);
135
136/** @} */
137
138#ifdef __cplusplus
139}
140#endif /* __cplusplus */
141
142#endif /* _RTEMS_SCORE_PROFILING */
Note: See TracBrowser for help on using the repository browser.