chstats.h 3.9 KB

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