tx_semaphore.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /***************************************************************************
  2. * Copyright (c) 2024 Microsoft Corporation
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the MIT License which is available at
  6. * https://opensource.org/licenses/MIT.
  7. *
  8. * SPDX-License-Identifier: MIT
  9. **************************************************************************/
  10. /**************************************************************************/
  11. /**************************************************************************/
  12. /** */
  13. /** ThreadX Component */
  14. /** */
  15. /** Semaphore */
  16. /** */
  17. /**************************************************************************/
  18. /**************************************************************************/
  19. /**************************************************************************/
  20. /* */
  21. /* COMPONENT DEFINITION RELEASE */
  22. /* */
  23. /* tx_semaphore.h PORTABLE C */
  24. /* 6.1 */
  25. /* AUTHOR */
  26. /* */
  27. /* William E. Lamie, Microsoft Corporation */
  28. /* */
  29. /* DESCRIPTION */
  30. /* */
  31. /* This file defines the ThreadX semaphore management component, */
  32. /* including all data types and external references. It is assumed */
  33. /* that tx_api.h and tx_port.h have already been included. */
  34. /* */
  35. /* RELEASE HISTORY */
  36. /* */
  37. /* DATE NAME DESCRIPTION */
  38. /* */
  39. /* 05-19-2020 William E. Lamie Initial Version 6.0 */
  40. /* 09-30-2020 Yuxin Zhou Modified comment(s), */
  41. /* resulting in version 6.1 */
  42. /* */
  43. /**************************************************************************/
  44. #ifndef TX_SEMAPHORE_H
  45. #define TX_SEMAPHORE_H
  46. /* Define semaphore control specific data definitions. */
  47. #define TX_SEMAPHORE_ID ((ULONG) 0x53454D41)
  48. /* Determine if in-line component initialization is supported by the
  49. caller. */
  50. #ifdef TX_INVOKE_INLINE_INITIALIZATION
  51. /* Yes, in-line initialization is supported, remap the
  52. semaphore initialization function. */
  53. #ifndef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO
  54. #define _tx_semaphore_initialize() \
  55. _tx_semaphore_created_ptr = TX_NULL; \
  56. _tx_semaphore_created_count = TX_EMPTY
  57. #else
  58. #define _tx_semaphore_initialize() \
  59. _tx_semaphore_created_ptr = TX_NULL; \
  60. _tx_semaphore_created_count = TX_EMPTY; \
  61. _tx_semaphore_performance_put_count = ((ULONG) 0); \
  62. _tx_semaphore_performance_get_count = ((ULONG) 0); \
  63. _tx_semaphore_performance_suspension_count = ((ULONG) 0); \
  64. _tx_semaphore_performance_timeout_count = ((ULONG) 0)
  65. #endif
  66. #define TX_SEMAPHORE_INIT
  67. #else
  68. /* No in-line initialization is supported, use standard
  69. function call. */
  70. VOID _tx_semaphore_initialize(VOID);
  71. #endif
  72. /* Define internal semaphore management function prototypes. */
  73. VOID _tx_semaphore_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence);
  74. /* Semaphore management component data declarations follow. */
  75. /* Determine if the initialization function of this component is including
  76. this file. If so, make the data definitions really happen. Otherwise,
  77. make them extern so other functions in the component can access them. */
  78. #ifdef TX_SEMAPHORE_INIT
  79. #define SEMAPHORE_DECLARE
  80. #else
  81. #define SEMAPHORE_DECLARE extern
  82. #endif
  83. /* Define the head pointer of the created semaphore list. */
  84. SEMAPHORE_DECLARE TX_SEMAPHORE * _tx_semaphore_created_ptr;
  85. /* Define the variable that holds the number of created semaphores. */
  86. SEMAPHORE_DECLARE ULONG _tx_semaphore_created_count;
  87. #ifdef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO
  88. /* Define the total number of semaphore puts. */
  89. SEMAPHORE_DECLARE ULONG _tx_semaphore_performance_put_count;
  90. /* Define the total number of semaphore gets. */
  91. SEMAPHORE_DECLARE ULONG _tx_semaphore_performance_get_count;
  92. /* Define the total number of semaphore suspensions. */
  93. SEMAPHORE_DECLARE ULONG _tx_semaphore_performance_suspension_count;
  94. /* Define the total number of semaphore timeouts. */
  95. SEMAPHORE_DECLARE ULONG _tx_semaphore_performance_timeout_count;
  96. #endif
  97. /* Define default post semaphore delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h). */
  98. #ifndef TX_SEMAPHORE_DELETE_PORT_COMPLETION
  99. #define TX_SEMAPHORE_DELETE_PORT_COMPLETION(s)
  100. #endif
  101. #endif