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 /**************************************************************************/ 14 /** */ 15 /** ThreadX Component */ 16 /** */ 17 /** Byte Pool */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #define TX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "tx_api.h" 28 #include "tx_byte_pool.h" 29 30 31 #ifndef TX_INLINE_INITIALIZATION 32 33 /* Locate byte pool component data in this file. */ 34 35 /* Define the head pointer of the created byte pool list. */ 36 37 TX_BYTE_POOL * _tx_byte_pool_created_ptr; 38 39 40 /* Define the variable that holds the number of created byte pools. */ 41 42 ULONG _tx_byte_pool_created_count; 43 44 45 #ifdef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO 46 47 /* Define the total number of allocates. */ 48 49 ULONG _tx_byte_pool_performance_allocate_count; 50 51 52 /* Define the total number of releases. */ 53 54 ULONG _tx_byte_pool_performance_release_count; 55 56 57 /* Define the total number of adjacent memory fragment merges. */ 58 59 ULONG _tx_byte_pool_performance_merge_count; 60 61 62 /* Define the total number of memory fragment splits. */ 63 64 ULONG _tx_byte_pool_performance_split_count; 65 66 67 /* Define the total number of memory fragments searched during allocation. */ 68 69 ULONG _tx_byte_pool_performance_search_count; 70 71 72 /* Define the total number of byte pool suspensions. */ 73 74 ULONG _tx_byte_pool_performance_suspension_count; 75 76 77 /* Define the total number of byte pool timeouts. */ 78 79 ULONG _tx_byte_pool_performance_timeout_count; 80 81 #endif 82 83 84 /**************************************************************************/ 85 /* */ 86 /* FUNCTION RELEASE */ 87 /* */ 88 /* _tx_byte_pool_initialize PORTABLE C */ 89 /* 6.1 */ 90 /* AUTHOR */ 91 /* */ 92 /* William E. Lamie, Microsoft Corporation */ 93 /* */ 94 /* DESCRIPTION */ 95 /* */ 96 /* This function initializes the various control data structures for */ 97 /* the byte pool component. */ 98 /* */ 99 /* INPUT */ 100 /* */ 101 /* None */ 102 /* */ 103 /* OUTPUT */ 104 /* */ 105 /* None */ 106 /* */ 107 /* CALLS */ 108 /* */ 109 /* None */ 110 /* */ 111 /* CALLED BY */ 112 /* */ 113 /* _tx_initialize_high_level High level initialization */ 114 /* */ 115 /* RELEASE HISTORY */ 116 /* */ 117 /* DATE NAME DESCRIPTION */ 118 /* */ 119 /* 05-19-2020 William E. Lamie Initial Version 6.0 */ 120 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 121 /* opt out of function when */ 122 /* TX_INLINE_INITIALIZATION is */ 123 /* defined, */ 124 /* resulting in version 6.1 */ 125 /* */ 126 /**************************************************************************/ _tx_byte_pool_initialize(VOID)127VOID _tx_byte_pool_initialize(VOID) 128 { 129 130 #ifndef TX_DISABLE_REDUNDANT_CLEARING 131 132 /* Initialize the head pointer of the created byte pools list and the 133 number of byte pools created. */ 134 _tx_byte_pool_created_ptr = TX_NULL; 135 _tx_byte_pool_created_count = TX_EMPTY; 136 137 #ifdef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO 138 139 /* Initialize byte pool performance counters. */ 140 _tx_byte_pool_performance_allocate_count = ((ULONG) 0); 141 _tx_byte_pool_performance_release_count = ((ULONG) 0); 142 _tx_byte_pool_performance_merge_count = ((ULONG) 0); 143 _tx_byte_pool_performance_split_count = ((ULONG) 0); 144 _tx_byte_pool_performance_search_count = ((ULONG) 0); 145 _tx_byte_pool_performance_suspension_count = ((ULONG) 0); 146 _tx_byte_pool_performance_timeout_count = ((ULONG) 0); 147 #endif 148 #endif 149 } 150 #endif 151