ChibiOS/RT 7.0.6
chstats.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006-2026 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 version 3 of the License.
9
10 ChibiOS is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/**
20 * @file rt/src/chstats.c
21 * @brief Statistics module code.
22 *
23 * @addtogroup statistics
24 * @details Statistics services.
25 * @{
26 */
27
28#include "ch.h"
29
30#if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__)
31
32/*===========================================================================*/
33/* Module local definitions. */
34/*===========================================================================*/
35
36/*===========================================================================*/
37/* Module exported variables. */
38/*===========================================================================*/
39
40/*===========================================================================*/
41/* Module local types. */
42/*===========================================================================*/
43
44/*===========================================================================*/
45/* Module local variables. */
46/*===========================================================================*/
47
48/*===========================================================================*/
49/* Module local functions. */
50/*===========================================================================*/
51
52/*===========================================================================*/
53/* Module exported functions. */
54/*===========================================================================*/
55
56/**
57 * @brief Increases the IRQ counter.
58 */
60
61 port_lock_from_isr();
62 currcore->kernel_stats.n_irq++;
63 port_unlock_from_isr();
64}
65
66/**
67 * @brief Updates context switch related statistics.
68 *
69 * @param[in] ntp the thread to be switched in
70 * @param[in] otp the thread to be switched out
71 */
73
74 currcore->kernel_stats.n_ctxswc++;
76}
77
78/**
79 * @brief Starts the measurement of a thread critical zone.
80 */
82
83 chTMStartMeasurementX(&currcore->kernel_stats.m_crit_thd);
84}
85
86/**
87 * @brief Stops the measurement of a thread critical zone.
88 */
90
91 chTMStopMeasurementX(&currcore->kernel_stats.m_crit_thd);
92}
93
94/**
95 * @brief Starts the measurement of an ISR critical zone.
96 */
98
99 chTMStartMeasurementX(&currcore->kernel_stats.m_crit_isr);
100}
101
102/**
103 * @brief Stops the measurement of an ISR critical zone.
104 */
106
107 chTMStopMeasurementX(&currcore->kernel_stats.m_crit_isr);
108}
109
110#endif /* CH_DBG_STATISTICS == TRUE */
111
112/** @} */
ChibiOS/RT main include file.
struct ch_thread thread_t
Type of a thread structure.
Definition chearly.h:132
void __stats_stop_measure_crit_isr(void)
Stops the measurement of an ISR critical zone.
Definition chstats.c:105
void __stats_ctxswc(thread_t *ntp, thread_t *otp)
Updates context switch related statistics.
Definition chstats.c:72
void __stats_start_measure_crit_isr(void)
Starts the measurement of an ISR critical zone.
Definition chstats.c:97
void __stats_increase_irq(void)
Increases the IRQ counter.
Definition chstats.c:59
void __stats_stop_measure_crit_thd(void)
Stops the measurement of a thread critical zone.
Definition chstats.c:89
void __stats_start_measure_crit_thd(void)
Starts the measurement of a thread critical zone.
Definition chstats.c:81
#define currcore
Access to current core's instance structure.
Definition chsys.h:89
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:125
NOINLINE void chTMStopMeasurementX(time_measurement_t *tmp)
Stops a measurement.
Definition chtm.c:108
NOINLINE void chTMStartMeasurementX(time_measurement_t *tmp)
Starts a measurement.
Definition chtm.c:95
time_measurement_t stats
Thread statistics.
Definition chobjects.h:346