RTEMS
profiling.h
Go to the documentation of this file.
1 
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
30 extern "C" {
31 #endif /* __cplusplus */
32 
52  Per_CPU_Control *cpu,
53  uint32_t previous_thread_dispatch_disable_level
54 )
55 {
56 #if defined( RTEMS_PROFILING )
57  if ( previous_thread_dispatch_disable_level == 0 ) {
58  Per_CPU_Stats *stats = &cpu->Stats;
59 
60  stats->thread_dispatch_disabled_instant = _CPU_Counter_read();
61  ++stats->thread_dispatch_disabled_count;
62  }
63 #else
64  (void) cpu;
65  (void) previous_thread_dispatch_disable_level;
66 #endif
67 }
68 
81  Per_CPU_Control *cpu,
82  uint32_t previous_thread_dispatch_disable_level,
83  const ISR_lock_Context *lock_context
84 )
85 {
86 #if defined( RTEMS_PROFILING )
87  if ( previous_thread_dispatch_disable_level == 0 ) {
88  Per_CPU_Stats *stats = &cpu->Stats;
89 
90  stats->thread_dispatch_disabled_instant = lock_context->ISR_disable_instant;
91  ++stats->thread_dispatch_disabled_count;
92  }
93 #else
94  (void) cpu;
95  (void) previous_thread_dispatch_disable_level;
96  (void) lock_context;
97 #endif
98 }
99 
110  Per_CPU_Control *cpu,
111  uint32_t new_thread_dispatch_disable_level
112 )
113 {
114 #if defined( RTEMS_PROFILING )
115  if ( new_thread_dispatch_disable_level == 0 ) {
116  Per_CPU_Stats *stats = &cpu->Stats;
117  CPU_Counter_ticks now = _CPU_Counter_read();
118  CPU_Counter_ticks delta = _CPU_Counter_difference(
119  now,
120  stats->thread_dispatch_disabled_instant
121  );
122 
123  stats->total_thread_dispatch_disabled_time += delta;
124 
125  if ( stats->max_thread_dispatch_disabled_time < delta ) {
126  stats->max_thread_dispatch_disabled_time = delta;
127  }
128  }
129 #else
130  (void) cpu;
131  (void) new_thread_dispatch_disable_level;
132 #endif
133 }
134 
142  Per_CPU_Control *cpu,
143  CPU_Counter_ticks interrupt_delay
144 )
145 {
146 #if defined( RTEMS_PROFILING )
147  Per_CPU_Stats *stats = &cpu->Stats;
148 
149  if ( stats->max_interrupt_delay < interrupt_delay ) {
150  stats->max_interrupt_delay = interrupt_delay;
151  }
152 #else
153  (void) cpu;
154  (void) interrupt_delay;
155 #endif
156 }
157 
169  Per_CPU_Control *cpu,
170  CPU_Counter_ticks interrupt_entry_instant,
171  CPU_Counter_ticks interrupt_exit_instant
172 );
173 
176 #ifdef __cplusplus
177 }
178 #endif /* __cplusplus */
179 
180 #endif /* _RTEMS_SCORE_PROFILING */
Per-CPU statistics.
Definition: percpu.h:236
static void _Profiling_Thread_dispatch_enable(Per_CPU_Control *cpu, uint32_t new_thread_dispatch_disable_level)
Enables the thread dispatch.
Definition: profiling.h:109
static void _Profiling_Thread_dispatch_disable_critical(Per_CPU_Control *cpu, uint32_t previous_thread_dispatch_disable_level, const ISR_lock_Context *lock_context)
Disables the thread dispatch.
Definition: profiling.h:80
Per CPU Core Structure.
Definition: percpu.h:347
void _Profiling_Outer_most_interrupt_entry_and_exit(Per_CPU_Control *cpu, CPU_Counter_ticks interrupt_entry_instant, CPU_Counter_ticks interrupt_exit_instant)
Updates the interrupt profiling statistics.
static void _Profiling_Update_max_interrupt_delay(Per_CPU_Control *cpu, CPU_Counter_ticks interrupt_delay)
Updates the maximum interrupt delay.
Definition: profiling.h:141
static void _Profiling_Thread_dispatch_disable(Per_CPU_Control *cpu, uint32_t previous_thread_dispatch_disable_level)
Disables the thread dispatch if the previous thread dispatch disable level is zero.
Definition: profiling.h:51
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
ISR Locks.