1
10
13
14
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
97
98
99
100
101
102
103
104
105
106
107
108
110
111
112
113
114
115
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
138
139
140
141
142
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
165
166
167
168
169
171
176
177
178
179
180
182
183
188
189
190
191
192
193
194
195
196
197
198
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
242
243
244
245
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
268
269
270
271
272
273
274
275
277
278
279
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
313
314
315
316
318
319
320
321
322
323
324
325
326
327
328
332
333
334
335
336
337
338
345
346
347
348
349
350
351
352
353
354
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
396
397
398
399
400
401
402
403
404
410
411
412
413
414
415
416
417
418
419
421
422
423
424
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
...
...
...
#define TX_SOURCE_CODE
#ifndef TX_NO_TIMER
#include "tx_api.h"
#include "tx_timer.h"
#include "tx_thread.h"
...
VOID _tx_timer_expiration_process(VOID)
{
TX_INTERRUPT_SAVE_AREA
#ifdef TX_TIMER_PROCESS_IN_ISR
TX_TIMER_INTERNAL *expired_timers;
TX_TIMER_INTERNAL *reactivate_timer;
TX_TIMER_INTERNAL *next_timer;
TX_TIMER_INTERNAL *previous_timer;
#ifdef TX_REACTIVATE_INLINE
TX_TIMER_INTERNAL **timer_list;
UINT expiration_time;
ULONG delta;/* ... */
#endif
TX_TIMER_INTERNAL *current_timer;
VOID (*timeout_function)(ULONG id);
ULONG timeout_param = ((ULONG) 0);
#ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
TX_TIMER *timer_ptr;
#endif/* ... */
#endif
#ifndef TX_TIMER_PROCESS_IN_ISR
/* ... */
TX_DISABLE
#ifdef TX_NOT_INTERRUPTABLE
_tx_thread_system_ni_resume(&_tx_timer_thread);
TX_RESTORE/* ... */
#else
_tx_thread_preempt_disable++;
TX_RESTORE
_tx_thread_system_resume(&_tx_timer_thread);/* ... */
#endif
/* ... */
#else
/* ... */
TX_DISABLE
/* ... */
if (_tx_timer_processing_active == TX_FALSE)
{
if (_tx_timer_expired != ((UINT) 0))
{
_tx_timer_processing_active = TX_TRUE;
do
{
/* ... */
expired_timers = *_tx_timer_current_ptr;
/* ... */
if (expired_timers != TX_NULL)
{
expired_timers -> tx_timer_internal_list_head = &expired_timers;
}if (expired_timers != TX_NULL) { ... }
*_tx_timer_current_ptr = TX_NULL;
/* ... */
_tx_timer_current_ptr = TX_TIMER_POINTER_ADD(_tx_timer_current_ptr, 1);
if (_tx_timer_current_ptr == _tx_timer_list_end)
{
_tx_timer_current_ptr = _tx_timer_list_start;
}if (_tx_timer_current_ptr == _tx_timer_list_end) { ... }
_tx_timer_expired = TX_FALSE;
TX_RESTORE
TX_DISABLE
/* ... */
while (expired_timers != TX_NULL)
{
current_timer = expired_timers;
next_timer = expired_timers -> tx_timer_internal_active_next;
reactivate_timer = TX_NULL;
if (current_timer == next_timer)
{
expired_timers = TX_NULL;
}if (current_timer == next_timer) { ... }
else
{
previous_timer = current_timer -> tx_timer_internal_active_previous;
next_timer -> tx_timer_internal_active_previous = previous_timer;
previous_timer -> tx_timer_internal_active_next = next_timer;
next_timer -> tx_timer_internal_list_head = &expired_timers;
expired_timers = next_timer;
}else { ... }
/* ... */
if (current_timer -> tx_timer_internal_remaining_ticks > TX_TIMER_ENTRIES)
{
/* ... */
#ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
_tx_timer_performance__expiration_adjust_count++;
if (current_timer -> tx_timer_internal_timeout_function != &_tx_thread_timeout)
{
TX_USER_TIMER_POINTER_GET(current_timer, timer_ptr)
if (timer_ptr -> tx_timer_id == TX_TIMER_ID)
{
timer_ptr -> tx_timer_performance__expiration_adjust_count++;
}if (timer_ptr -> tx_timer_id == TX_TIMER_ID) { ... }
}if (current_timer -> tx_timer_internal_timeout_function != &_tx_thread_timeout) { ... }
/* ... */#endif
current_timer -> tx_timer_internal_remaining_ticks =
current_timer -> tx_timer_internal_remaining_ticks - TX_TIMER_ENTRIES;
/* ... */
timeout_function = TX_NULL;
/* ... */
current_timer -> tx_timer_internal_list_head = &reactivate_timer;
current_timer -> tx_timer_internal_active_next = current_timer;
reactivate_timer = current_timer;
}if (current_timer -> tx_timer_internal_remaining_ticks > TX_TIMER_ENTRIES) { ... }
else
{
#ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
_tx_timer_performance_expiration_count++;
if (current_timer -> tx_timer_internal_timeout_function != &_tx_thread_timeout)
{
TX_USER_TIMER_POINTER_GET(current_timer, timer_ptr)
if (timer_ptr -> tx_timer_id == TX_TIMER_ID)
{
timer_ptr -> tx_timer_performance_expiration_count++;
}if (timer_ptr -> tx_timer_id == TX_TIMER_ID) { ... }
}if (current_timer -> tx_timer_internal_timeout_function != &_tx_thread_timeout) { ... }
/* ... */#endif
/* ... */
timeout_function = current_timer -> tx_timer_internal_timeout_function;
timeout_param = current_timer -> tx_timer_internal_timeout_param;
current_timer -> tx_timer_internal_remaining_ticks = current_timer -> tx_timer_internal_re_initialize_ticks;
if (current_timer -> tx_timer_internal_remaining_ticks != ((ULONG) 0))
{
/* ... */
current_timer -> tx_timer_internal_list_head = &reactivate_timer;
current_timer -> tx_timer_internal_active_next = current_timer;
reactivate_timer = current_timer;
}if (current_timer -> tx_timer_internal_remaining_ticks != ((ULONG) 0)) { ... }
else
{
/* ... */
current_timer -> tx_timer_internal_list_head = TX_NULL;
}else { ... }
}else { ... }
_tx_timer_expired_timer_ptr = current_timer;
TX_RESTORE
if (timeout_function != TX_NULL)
{
(timeout_function) (timeout_param);
}if (timeout_function != TX_NULL) { ... }
TX_DISABLE
_tx_timer_expired_timer_ptr = TX_NULL;
if (reactivate_timer == current_timer)
{
#ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
if (timeout_function != TX_NULL)
{
_tx_timer_performance_reactivate_count++;
if (current_timer -> tx_timer_internal_timeout_function != &_tx_thread_timeout)
{
TX_USER_TIMER_POINTER_GET(current_timer, timer_ptr)
if (timer_ptr -> tx_timer_id == TX_TIMER_ID)
{
timer_ptr -> tx_timer_performance_reactivate_count++;
}if (timer_ptr -> tx_timer_id == TX_TIMER_ID) { ... }
}if (current_timer -> tx_timer_internal_timeout_function != &_tx_thread_timeout) { ... }
}if (timeout_function != TX_NULL) { ... }
/* ... */#endif
#ifdef TX_REACTIVATE_INLINE
if (current_timer -> tx_timer_internal_remaining_ticks > TX_TIMER_ENTRIES)
{
expiration_time = TX_TIMER_ENTRIES - ((UINT) 1);
}if (current_timer -> tx_timer_internal_remaining_ticks > TX_TIMER_ENTRIES) { ... }
else
{
expiration_time = ((UINT) current_timer -> tx_timer_internal_remaining_ticks) - ((UINT) 1);
}else { ... }
/* ... */
timer_list = TX_TIMER_POINTER_ADD(_tx_timer_current_ptr, expiration_time);
if (TX_TIMER_INDIRECT_TO_VOID_POINTER_CONVERT(timer_list) >= TX_TIMER_INDIRECT_TO_VOID_POINTER_CONVERT(_tx_timer_list_end))
{
delta = TX_TIMER_POINTER_DIF(timer_list, _tx_timer_list_end);
timer_list = TX_TIMER_POINTER_ADD(_tx_timer_list_start, delta);
}if (TX_TIMER_INDIRECT_TO_VOID_POINTER_CONVERT(timer_list) >= TX_TIMER_INDIRECT_TO_VOID_POINTER_CONVERT(_tx_timer_list_end)) { ... }
if ((*timer_list) == TX_NULL)
{
current_timer -> tx_timer_internal_active_next = current_timer;
current_timer -> tx_timer_internal_active_previous = current_timer;
*timer_list = current_timer;
}if ((*timer_list) == TX_NULL) { ... }
else
{
next_timer = *timer_list;
previous_timer = next_timer -> tx_timer_internal_active_previous;
previous_timer -> tx_timer_internal_active_next = current_timer;
next_timer -> tx_timer_internal_active_previous = current_timer;
current_timer -> tx_timer_internal_active_next = next_timer;
current_timer -> tx_timer_internal_active_previous = previous_timer;
}else { ... }
current_timer -> tx_timer_internal_list_head = timer_list;/* ... */
#else
current_timer -> tx_timer_internal_list_head = TX_NULL;
_tx_timer_system_activate(current_timer);/* ... */
#endif
}if (reactivate_timer == current_timer) { ... }
}while (expired_timers != TX_NULL) { ... }
...} while (_tx_timer_expired != TX_FALSE);
_tx_timer_processing_active = TX_FALSE;
}if (_tx_timer_expired != ((UINT) 0)) { ... }
}if (_tx_timer_processing_active == TX_FALSE) { ... }
TX_RESTORE/* ... */
#endif
}{ ... }
...#endif/* ... */