ChibiOS/RT  5.1.0
chstats.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio.
3 
4  This file is part of ChibiOS.
5 
6  ChibiOS is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  ChibiOS is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /**
21  * @file chstats.h
22  * @brief Statistics module macros and structures.
23  *
24  * @addtogroup statistics
25  * @{
26  */
27 
28 #ifndef CHSTATS_H
29 #define CHSTATS_H
30 
31 #if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__)
32 
33 /*===========================================================================*/
34 /* Module constants. */
35 /*===========================================================================*/
36 
37 /*===========================================================================*/
38 /* Module pre-compile time settings. */
39 /*===========================================================================*/
40 
41 #if CH_CFG_USE_TM == FALSE
42 #error "CH_DBG_STATISTICS requires CH_CFG_USE_TM"
43 #endif
44 
45 /*===========================================================================*/
46 /* Derived constants and error checks. */
47 /*===========================================================================*/
48 
49 /*===========================================================================*/
50 /* Module data structures and types. */
51 /*===========================================================================*/
52 
53 /**
54  * @brief Type of a kernel statistics structure.
55  */
56 typedef struct {
57  ucnt_t n_irq; /**< @brief Number of IRQs. */
58  ucnt_t n_ctxswc; /**< @brief Number of context switches. */
59  time_measurement_t m_crit_thd; /**< @brief Measurement of threads
60  critical zones duration. */
61  time_measurement_t m_crit_isr; /**< @brief Measurement of ISRs critical
62  zones duration. */
64 
65 /*===========================================================================*/
66 /* Module macros. */
67 /*===========================================================================*/
68 
69 /*===========================================================================*/
70 /* External declarations. */
71 /*===========================================================================*/
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76  void _stats_init(void);
77  void _stats_increase_irq(void);
78  void _stats_ctxswc(thread_t *ntp, thread_t *otp);
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 /*===========================================================================*/
88 /* Module inline functions. */
89 /*===========================================================================*/
90 
91 #else /* CH_DBG_STATISTICS == FALSE */
92 
93 /* Stub functions for when the statistics module is disabled. */
94 #define _stats_increase_irq()
95 #define _stats_ctxswc(old, new)
96 #define _stats_start_measure_crit_thd()
97 #define _stats_stop_measure_crit_thd()
98 #define _stats_start_measure_crit_isr()
99 #define _stats_stop_measure_crit_isr()
100 
101 #endif /* CH_DBG_STATISTICS == FALSE */
102 
103 #endif /* CHSTATS_H */
104 
105 /** @} */
void _stats_start_measure_crit_thd(void)
Starts the measurement of a thread critical zone.
Definition: chstats.c:95
Type of a Time Measurement object.
Definition: chtm.h:72
void _stats_stop_measure_crit_thd(void)
Stops the measurement of a thread critical zone.
Definition: chstats.c:103
time_measurement_t m_crit_isr
Measurement of ISRs critical zones duration.
Definition: chstats.h:61
void _stats_ctxswc(thread_t *ntp, thread_t *otp)
Updates context switch related statistics.
Definition: chstats.c:86
ucnt_t n_irq
Number of IRQs.
Definition: chstats.h:57
ucnt_t n_ctxswc
Number of context switches.
Definition: chstats.h:58
void _stats_init(void)
Initializes the statistics module.
Definition: chstats.c:62
Type of a kernel statistics structure.
Definition: chstats.h:56
void _stats_increase_irq(void)
Increases the IRQ counter.
Definition: chstats.c:73
void _stats_start_measure_crit_isr(void)
Starts the measurement of an ISR critical zone.
Definition: chstats.c:111
time_measurement_t m_crit_thd
Measurement of threads critical zones duration.
Definition: chstats.h:59
void _stats_stop_measure_crit_isr(void)
Stops the measurement of an ISR critical zone.
Definition: chstats.c:119
Structure representing a thread.
Definition: chschd.h:153