ChibiOS/RT 7.0.5
chstats.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
3 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
4
5 This file is part of ChibiOS.
6
7 ChibiOS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation version 3 of the License.
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 rt/src/chstats.c
22 * @brief Statistics module code.
23 *
24 * @addtogroup statistics
25 * @details Statistics services.
26 * @{
27 */
28
29#include "ch.h"
30
31#if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__)
32
33/*===========================================================================*/
34/* Module local definitions. */
35/*===========================================================================*/
36
37/*===========================================================================*/
38/* Module exported variables. */
39/*===========================================================================*/
40
41/*===========================================================================*/
42/* Module local types. */
43/*===========================================================================*/
44
45/*===========================================================================*/
46/* Module local variables. */
47/*===========================================================================*/
48
49/*===========================================================================*/
50/* Module local functions. */
51/*===========================================================================*/
52
53/*===========================================================================*/
54/* Module exported functions. */
55/*===========================================================================*/
56
57/**
58 * @brief Increases the IRQ counter.
59 */
61
62 port_lock_from_isr();
63 currcore->kernel_stats.n_irq++;
64 port_unlock_from_isr();
65}
66
67/**
68 * @brief Updates context switch related statistics.
69 *
70 * @param[in] ntp the thread to be switched in
71 * @param[in] otp the thread to be switched out
72 */
74
75 currcore->kernel_stats.n_ctxswc++;
77}
78
79/**
80 * @brief Starts the measurement of a thread critical zone.
81 */
83
84 chTMStartMeasurementX(&currcore->kernel_stats.m_crit_thd);
85}
86
87/**
88 * @brief Stops the measurement of a thread critical zone.
89 */
91
92 chTMStopMeasurementX(&currcore->kernel_stats.m_crit_thd);
93}
94
95/**
96 * @brief Starts the measurement of an ISR critical zone.
97 */
99
100 chTMStartMeasurementX(&currcore->kernel_stats.m_crit_isr);
101}
102
103/**
104 * @brief Stops the measurement of an ISR critical zone.
105 */
107
108 chTMStopMeasurementX(&currcore->kernel_stats.m_crit_isr);
109}
110
111#endif /* CH_DBG_STATISTICS == TRUE */
112
113/** @} */
ChibiOS/RT main include file.
struct ch_thread thread_t
Type of a thread structure.
Definition chearly.h:133
void __stats_stop_measure_crit_isr(void)
Stops the measurement of an ISR critical zone.
Definition chstats.c:106
void __stats_ctxswc(thread_t *ntp, thread_t *otp)
Updates context switch related statistics.
Definition chstats.c:73
void __stats_start_measure_crit_isr(void)
Starts the measurement of an ISR critical zone.
Definition chstats.c:98
void __stats_increase_irq(void)
Increases the IRQ counter.
Definition chstats.c:60
void __stats_stop_measure_crit_thd(void)
Stops the measurement of a thread critical zone.
Definition chstats.c:90
void __stats_start_measure_crit_thd(void)
Starts the measurement of a thread critical zone.
Definition chstats.c:82
#define currcore
Access to current core's instance structure.
Definition chsys.h:90
NOINLINE void chTMChainMeasurementToX(time_measurement_t *tmp1, time_measurement_t *tmp2)
Stops a measurement and chains to the next one using the same time stamp.
Definition chtm.c:126
NOINLINE void chTMStopMeasurementX(time_measurement_t *tmp)
Stops a measurement.
Definition chtm.c:109
NOINLINE void chTMStartMeasurementX(time_measurement_t *tmp)
Starts a measurement.
Definition chtm.c:96
time_measurement_t stats
Thread statistics.
Definition chobjects.h:337