1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** ThreadX Component */ 17 /** */ 18 /** Semaphore */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #define TX_SOURCE_CODE 24 25 26 /* Include necessary system files. */ 27 28 #include "tx_api.h" 29 #include "tx_semaphore.h" 30 31 32 #ifndef TX_INLINE_INITIALIZATION 33 34 /* Locate semaphore component data in this file. */ 35 36 /* Define the head pointer of the created semaphore list. */ 37 38 TX_SEMAPHORE * _tx_semaphore_created_ptr; 39 40 41 /* Define the variable that holds the number of created semaphores. */ 42 43 ULONG _tx_semaphore_created_count; 44 45 46 #ifdef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO 47 48 /* Define the total number of semaphore puts. */ 49 50 ULONG _tx_semaphore_performance_put_count; 51 52 53 /* Define the total number of semaphore gets. */ 54 55 ULONG _tx_semaphore_performance_get_count; 56 57 58 /* Define the total number of semaphore suspensions. */ 59 60 ULONG _tx_semaphore_performance_suspension_count; 61 62 63 /* Define the total number of semaphore timeouts. */ 64 65 ULONG _tx_semaphore_performance_timeout_count; 66 67 #endif 68 69 70 /**************************************************************************/ 71 /* */ 72 /* FUNCTION RELEASE */ 73 /* */ 74 /* _tx_semaphore_initialize PORTABLE C */ 75 /* 6.1 */ 76 /* AUTHOR */ 77 /* */ 78 /* William E. Lamie, Microsoft Corporation */ 79 /* */ 80 /* DESCRIPTION */ 81 /* */ 82 /* This function initializes the various control data structures for */ 83 /* the semaphore component. */ 84 /* */ 85 /* INPUT */ 86 /* */ 87 /* None */ 88 /* */ 89 /* OUTPUT */ 90 /* */ 91 /* None */ 92 /* */ 93 /* CALLS */ 94 /* */ 95 /* None */ 96 /* */ 97 /* CALLED BY */ 98 /* */ 99 /* _tx_initialize_high_level High level initialization */ 100 /* */ 101 /* RELEASE HISTORY */ 102 /* */ 103 /* DATE NAME DESCRIPTION */ 104 /* */ 105 /* 05-19-2020 William E. Lamie Initial Version 6.0 */ 106 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 107 /* opt out of function when */ 108 /* TX_INLINE_INITIALIZATION is */ 109 /* defined, */ 110 /* resulting in version 6.1 */ 111 /* */ 112 /**************************************************************************/ _tx_semaphore_initialize(VOID)113VOID _tx_semaphore_initialize(VOID) 114 { 115 116 #ifndef TX_DISABLE_REDUNDANT_CLEARING 117 118 /* Initialize the head pointer of the created semaphores list and the 119 number of semaphores created. */ 120 _tx_semaphore_created_ptr = TX_NULL; 121 _tx_semaphore_created_count = TX_EMPTY; 122 123 #ifdef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO 124 125 /* Initialize semaphore performance counters. */ 126 _tx_semaphore_performance_put_count = ((ULONG) 0); 127 _tx_semaphore_performance_get_count = ((ULONG) 0); 128 _tx_semaphore_performance_suspension_count = ((ULONG) 0); 129 _tx_semaphore_performance_timeout_count = ((ULONG) 0); 130 #endif 131 #endif 132 } 133 #endif 134