1
10
13
14
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
41
42
43
44
45
47
48
49
50
51
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
73
74
75
76
77
81
82
83
84
85
88
89
90
91
92
93
94
95
96
101
102
103
104
105
108
109
110
111
112
113
114
117
118
119
120
121
125
126
127
128
129
132
133
134
135
136
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
186
187
188
189
190
192
193
194
195
196
198
199
200
201
202
204
205
206
207
208
211
212
213
214
215
217
218
219
220
221
224
225
226
227
228
231
232
233
234
235
237
238
239
240
241
243
244
245
246
247
249
250
251
252
253
255
256
257
258
259
261
262
263
264
265
266
267
268
269
270
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
346
347
348
349
350
351
352
353
354
356
357
358
359
360
361
362
363
364
365
366
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
...
...
...
#define TX_SOURCE_CODE
#ifndef TX_MISRA_ENABLE
#define TX_THREAD_INIT
#endif
#include "tx_api.h"
#include "tx_initialize.h"
#include "tx_thread.h"
/* ... */
VOID * _tx_thread_system_stack_ptr;
/* ... */
TX_THREAD * _tx_thread_current_ptr;
/* ... */
TX_THREAD * _tx_thread_execute_ptr;
TX_THREAD * _tx_thread_created_ptr;
ULONG _tx_thread_created_count;
/* ... */
volatile ULONG _tx_thread_system_state = TX_INITIALIZE_IN_PROGRESS;
/* ... */
ULONG _tx_thread_priority_maps[TX_MAX_PRIORITIES/32];
/* ... */
#if TX_MAX_PRIORITIES > 32
ULONG _tx_thread_priority_map_active;
#endif
#ifndef TX_DISABLE_PREEMPTION_THRESHOLD
/* ... */
ULONG _tx_thread_preempted_maps[TX_MAX_PRIORITIES/32];
/* ... */
#if TX_MAX_PRIORITIES > 32
ULONG _tx_thread_preempted_map_active;
#endif/* ... */
#endif
/* ... */
UINT _tx_thread_highest_priority;
/* ... */
TX_THREAD * _tx_thread_priority_list[TX_MAX_PRIORITIES];
/* ... */
volatile UINT _tx_thread_preempt_disable;
/* ... */
VOID (*_tx_thread_mutex_release)(TX_THREAD *thread_ptr);
/* ... */
ULONG _tx_build_options;
#if defined(TX_ENABLE_STACK_CHECKING) || defined(TX_PORT_THREAD_STACK_ERROR_HANDLING)
/* ... */
VOID (*_tx_thread_application_stack_error_handler)(TX_THREAD *thread_ptr);
/* ... */
#endif
#ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO
/* ... */
ULONG _tx_thread_performance_resume_count;
/* ... */
ULONG _tx_thread_performance_suspend_count;
/* ... */
ULONG _tx_thread_performance_solicited_preemption_count;
/* ... */
ULONG _tx_thread_performance_interrupt_preemption_count;
/* ... */
ULONG _tx_thread_performance_priority_inversion_count;
/* ... */
ULONG _tx_thread_performance_time_slice_count;
/* ... */
ULONG _tx_thread_performance_relinquish_count;
/* ... */
ULONG _tx_thread_performance_timeout_count;
/* ... */
ULONG _tx_thread_performance_wait_abort_count;
/* ... */
ULONG _tx_thread_performance_idle_return_count;
/* ... */
ULONG _tx_thread_performance_non_idle_return_count;
/* ... */
ULONG _tx_thread_performance__execute_log_index;
TX_THREAD * _tx_thread_performance_execute_log[TX_THREAD_EXECUTE_LOG_SIZE];/* ... */
#endif
#ifndef TX_MISRA_ENABLE
const CHAR _tx_thread_special_string[] =
"G-ML-EL-ML-BL-DL-BL-GB-GL-M-D-DL-GZ-KH-EL-CM-NH-HA-GF-DD-JC-YZ-CT-AT-DW-USA-CA-SD-SDSU";/* ... */
#endif
...
...
VOID _tx_thread_initialize(VOID)
{
/* ... */
#ifndef TX_DISABLE_REDUNDANT_CLEARING
TX_THREAD_SET_CURRENT(TX_NULL)
_tx_thread_execute_ptr = TX_NULL;
TX_MEMSET(&_tx_thread_priority_maps[0], 0, (sizeof(_tx_thread_priority_maps)));
#ifndef TX_DISABLE_PREEMPTION_THRESHOLD
TX_MEMSET(&_tx_thread_preempted_maps[0], 0, (sizeof(_tx_thread_preempted_maps)));
#endif/* ... */
#endif
/* ... */
_tx_thread_highest_priority = ((UINT) TX_MAX_PRIORITIES);
#ifndef TX_DISABLE_REDUNDANT_CLEARING
TX_MEMSET(&_tx_thread_priority_list[0], 0, (sizeof(_tx_thread_priority_list)));
/* ... */
_tx_thread_created_ptr = TX_NULL;
_tx_thread_created_count = TX_EMPTY;
_tx_thread_preempt_disable = ((UINT) 0);
_tx_thread_mutex_release = TX_NULL;
#ifdef TX_ENABLE_STACK_CHECKING
_tx_thread_application_stack_error_handler = TX_NULL;/* ... */
#endif
#ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO
_tx_thread_performance_resume_count = ((ULONG) 0);
_tx_thread_performance_suspend_count = ((ULONG) 0);
_tx_thread_performance_solicited_preemption_count = ((ULONG) 0);
_tx_thread_performance_interrupt_preemption_count = ((ULONG) 0);
_tx_thread_performance_priority_inversion_count = ((ULONG) 0);
_tx_thread_performance_time_slice_count = ((ULONG) 0);
_tx_thread_performance_relinquish_count = ((ULONG) 0);
_tx_thread_performance_timeout_count = ((ULONG) 0);
_tx_thread_performance_wait_abort_count = ((ULONG) 0);
_tx_thread_performance_idle_return_count = ((ULONG) 0);
_tx_thread_performance_non_idle_return_count = ((ULONG) 0);
TX_MEMSET(&_tx_thread_performance_execute_log[0], 0, (sizeof(_tx_thread_performance_execute_log)));/* ... */
#endif/* ... */
#endif
_tx_build_options = _tx_build_options
| (((ULONG) (TX_MAX_PRIORITIES/32)) << 24)
#ifdef TX_NOT_INTERRUPTABLE
| (((ULONG) 1) << 31)
#endif
#ifdef TX_INLINE_THREAD_RESUME_SUSPEND
| (((ULONG) 1) << 30)
#endif
#ifdef TX_TIMER_PROCESS_IN_ISR
| (((ULONG) 1) << 23)
#endif
#ifdef TX_REACTIVATE_INLINE
| (((ULONG) 1) << 22)
#endif
#ifdef TX_DISABLE_STACK_FILLING
| (((ULONG) 1) << 21)
#endif
#ifdef TX_ENABLE_STACK_CHECKING
| (((ULONG) 1) << 20)
#endif
#ifdef TX_DISABLE_PREEMPTION_THRESHOLD
| (((ULONG) 1) << 19)
#endif
#ifdef TX_DISABLE_REDUNDANT_CLEARING
| (((ULONG) 1) << 18)
#endif
#ifdef TX_DISABLE_NOTIFY_CALLBACKS
| (((ULONG) 1) << 17)
#endif
#ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
| (((ULONG) 1) << 16)
#endif
#ifdef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO
| (((ULONG) 1) << 15)
#endif
#ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
| (((ULONG) 1) << 14)
#endif
#ifdef TX_MUTEX_ENABLE_PERFORMANCE_INFO
| (((ULONG) 1) << 13)
#endif
#ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO
| (((ULONG) 1) << 12)
#endif
#ifdef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO
| (((ULONG) 1) << 11)
#endif
#ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO
| (((ULONG) 1) << 10)
#endif
#ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
| (((ULONG) 1) << 9)
#endif
#ifdef TX_ENABLE_EVENT_TRACE
| (((ULONG) 1) << 8)
#endif
#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE)
| (((ULONG) 1) << 7)
#endif
#if TX_PORT_SPECIFIC_BUILD_OPTIONS != 0
| TX_PORT_SPECIFIC_BUILD_OPTIONS
#endif
;
}{ ... }