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 /** Mutex */
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_mutex.h"
30 #ifdef TX_MUTEX_ENABLE_PERFORMANCE_INFO
31 #include "tx_trace.h"
32 #endif
33
34
35 /**************************************************************************/
36 /* */
37 /* FUNCTION RELEASE */
38 /* */
39 /* _tx_mutex_performance_system_info_get PORTABLE C */
40 /* 6.1 */
41 /* AUTHOR */
42 /* */
43 /* William E. Lamie, Microsoft Corporation */
44 /* */
45 /* DESCRIPTION */
46 /* */
47 /* This function retrieves system mutex performance information. */
48 /* */
49 /* INPUT */
50 /* */
51 /* puts Destination for total number of */
52 /* mutex puts */
53 /* gets Destination for total number of */
54 /* mutex gets */
55 /* suspensions Destination for total number of */
56 /* mutex suspensions */
57 /* timeouts Destination for total number of */
58 /* mutex timeouts */
59 /* inversions Destination for total number of */
60 /* mutex priority inversions */
61 /* inheritances Destination for total number of */
62 /* mutex priority inheritances */
63 /* */
64 /* OUTPUT */
65 /* */
66 /* status Completion status */
67 /* */
68 /* CALLS */
69 /* */
70 /* None */
71 /* */
72 /* CALLED BY */
73 /* */
74 /* Application Code */
75 /* */
76 /* RELEASE HISTORY */
77 /* */
78 /* DATE NAME DESCRIPTION */
79 /* */
80 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
81 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
82 /* resulting in version 6.1 */
83 /* */
84 /**************************************************************************/
_tx_mutex_performance_system_info_get(ULONG * puts,ULONG * gets,ULONG * suspensions,ULONG * timeouts,ULONG * inversions,ULONG * inheritances)85 UINT _tx_mutex_performance_system_info_get(ULONG *puts, ULONG *gets, ULONG *suspensions,
86 ULONG *timeouts, ULONG *inversions, ULONG *inheritances)
87 {
88
89 #ifdef TX_MUTEX_ENABLE_PERFORMANCE_INFO
90
91 TX_INTERRUPT_SAVE_AREA
92
93
94 /* Disable interrupts. */
95 TX_DISABLE
96
97 /* If trace is enabled, insert this event into the trace buffer. */
98 TX_TRACE_IN_LINE_INSERT(TX_TRACE_MUTEX_PERFORMANCE_SYSTEM_INFO_GET, 0, 0, 0, 0, TX_TRACE_MUTEX_EVENTS)
99
100 /* Log this kernel call. */
101 TX_EL_MUTEX_PERFORMANCE_SYSTEM_INFO_GET_INSERT
102
103 /* Retrieve all the pertinent information and return it in the supplied
104 destinations. */
105
106 /* Retrieve the total number of mutex puts. */
107 if (puts != TX_NULL)
108 {
109
110 *puts = _tx_mutex_performance_put_count;
111 }
112
113 /* Retrieve the total number of mutex gets. */
114 if (gets != TX_NULL)
115 {
116
117 *gets = _tx_mutex_performance_get_count;
118 }
119
120 /* Retrieve the total number of mutex suspensions. */
121 if (suspensions != TX_NULL)
122 {
123
124 *suspensions = _tx_mutex_performance_suspension_count;
125 }
126
127 /* Retrieve the total number of mutex timeouts. */
128 if (timeouts != TX_NULL)
129 {
130
131 *timeouts = _tx_mutex_performance_timeout_count;
132 }
133
134 /* Retrieve the total number of mutex priority inversions. */
135 if (inversions != TX_NULL)
136 {
137
138 *inversions = _tx_mutex_performance_priority_inversion_count;
139 }
140
141 /* Retrieve the total number of mutex priority inheritances. */
142 if (inheritances != TX_NULL)
143 {
144
145 *inheritances = _tx_mutex_performance__priority_inheritance_count;
146 }
147
148 /* Restore interrupts. */
149 TX_RESTORE
150
151 /* Return completion status. */
152 return(TX_SUCCESS);
153
154 #else
155
156 UINT status;
157
158
159 /* Access input arguments just for the sake of lint, MISRA, etc. */
160 if (puts != TX_NULL)
161 {
162
163 /* Not enabled, return error. */
164 status = TX_FEATURE_NOT_ENABLED;
165 }
166 else if (gets != TX_NULL)
167 {
168
169 /* Not enabled, return error. */
170 status = TX_FEATURE_NOT_ENABLED;
171 }
172 else if (suspensions != TX_NULL)
173 {
174
175 /* Not enabled, return error. */
176 status = TX_FEATURE_NOT_ENABLED;
177 }
178 else if (timeouts != TX_NULL)
179 {
180
181 /* Not enabled, return error. */
182 status = TX_FEATURE_NOT_ENABLED;
183 }
184 else if (inversions != TX_NULL)
185 {
186
187 /* Not enabled, return error. */
188 status = TX_FEATURE_NOT_ENABLED;
189 }
190 else if (inheritances != TX_NULL)
191 {
192
193 /* Not enabled, return error. */
194 status = TX_FEATURE_NOT_ENABLED;
195 }
196 else
197 {
198
199 /* Not enabled, return error. */
200 status = TX_FEATURE_NOT_ENABLED;
201 }
202
203 /* Return completion status. */
204 return(status);
205 #endif
206 }
207
208