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 /**   Block Memory                                                        */
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_block_pool.h"
30 #ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
31 #include "tx_trace.h"
32 #endif
33 
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _tx_block_pool_performance_system_info_get          PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    William E. Lamie, Microsoft Corporation                             */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function retrieves block pool performance information.         */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    allocates                         Destination for the total number  */
51 /*                                        of block allocations            */
52 /*    releases                          Destination for the total number  */
53 /*                                        of blocks released              */
54 /*    suspensions                       Destination for the total number  */
55 /*                                        of suspensions                  */
56 /*    timeouts                          Destination for total number of   */
57 /*                                        timeouts                        */
58 /*                                                                        */
59 /*  OUTPUT                                                                */
60 /*                                                                        */
61 /*    status                            Completion status                 */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    None                                                                */
66 /*                                                                        */
67 /*  CALLED BY                                                             */
68 /*                                                                        */
69 /*    Application Code                                                    */
70 /*                                                                        */
71 /*  RELEASE HISTORY                                                       */
72 /*                                                                        */
73 /*    DATE              NAME                      DESCRIPTION             */
74 /*                                                                        */
75 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
76 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
77 /*                                            resulting in version 6.1    */
78 /*                                                                        */
79 /**************************************************************************/
_tx_block_pool_performance_system_info_get(ULONG * allocates,ULONG * releases,ULONG * suspensions,ULONG * timeouts)80 UINT  _tx_block_pool_performance_system_info_get(ULONG *allocates, ULONG *releases, ULONG *suspensions, ULONG *timeouts)
81 {
82 
83 #ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
84 
85 TX_INTERRUPT_SAVE_AREA
86 
87 
88     /* Disable interrupts.  */
89     TX_DISABLE
90 
91     /* If trace is enabled, insert this event into the trace buffer.  */
92     TX_TRACE_IN_LINE_INSERT(TX_TRACE_BLOCK_POOL__PERFORMANCE_SYSTEM_INFO_GET, 0, 0, 0, 0, TX_TRACE_BLOCK_POOL_EVENTS)
93 
94     /* Log this kernel call.  */
95     TX_EL_BLOCK_POOL_PERFORMANCE_SYSTEM_INFO_GET_INSERT
96 
97     /* Retrieve all the pertinent information and return it in the supplied
98        destinations.  */
99 
100     /* Retrieve the total number of block allocations.  */
101     if (allocates != TX_NULL)
102     {
103 
104         *allocates =  _tx_block_pool_performance_allocate_count;
105     }
106 
107     /* Retrieve the total number of blocks released.  */
108     if (releases != TX_NULL)
109     {
110 
111         *releases =  _tx_block_pool_performance_release_count;
112     }
113 
114     /* Retrieve the total number of block pool thread suspensions.  */
115     if (suspensions != TX_NULL)
116     {
117 
118         *suspensions =  _tx_block_pool_performance_suspension_count;
119     }
120 
121     /* Retrieve the total number of block pool thread timeouts.  */
122     if (timeouts != TX_NULL)
123     {
124 
125         *timeouts =  _tx_block_pool_performance_timeout_count;
126     }
127 
128     /* Restore interrupts.  */
129     TX_RESTORE
130 
131     /* Return completion status.  */
132     return(TX_SUCCESS);
133 
134 #else
135 
136 UINT        status;
137 
138 
139     /* Access input arguments just for the sake of lint, MISRA, etc.  */
140     if (allocates != TX_NULL)
141     {
142 
143         /* Not enabled, return error.  */
144         status =  TX_FEATURE_NOT_ENABLED;
145     }
146     else if (releases != TX_NULL)
147     {
148 
149         /* Not enabled, return error.  */
150         status =  TX_FEATURE_NOT_ENABLED;
151     }
152     else if (suspensions != TX_NULL)
153     {
154 
155         /* Not enabled, return error.  */
156         status =  TX_FEATURE_NOT_ENABLED;
157     }
158     else if (timeouts != TX_NULL)
159     {
160 
161         /* Not enabled, return error.  */
162         status =  TX_FEATURE_NOT_ENABLED;
163     }
164     else
165     {
166 
167         /* Not enabled, return error.  */
168         status =  TX_FEATURE_NOT_ENABLED;
169     }
170 
171     /* Return completion status.  */
172     return(status);
173 #endif
174 }
175 
176