RTEMS  5.0.0
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 
43 static 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 
61 static 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 
81 static 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 
107 static 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 
131  Per_CPU_Control *cpu,
132  CPU_Counter_ticks interrupt_entry_instant,
133  CPU_Counter_ticks interrupt_exit_instant
134 );
135 
138 #ifdef __cplusplus
139 }
140 #endif /* __cplusplus */
141 
142 #endif /* _RTEMS_SCORE_PROFILING */
Per-CPU statistics.
Definition: percpu.h:179
CPU_Counter_ticks _CPU_Counter_read(void)
Returns the current CPU counter value.
Definition: system-clocks.c:117
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.
Definition: profilingisrentryexit.c:22
Per CPU Core Structure.
Definition: percpu.h:290
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
ISR Locks.