1
10
13
14
20
21
22
23
24
25
26
27
28
29
30
31
32
33
35
36
37
38
39
41
42
43
44
45
47
48
49
50
51
53
54
55
56
57
59
60
61
62
63
64
66
67
68
69
70
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
114
115
116
117
118
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
152
153
154
155
156
157
158
159
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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
239
240
241
242
243
244
246
247
248
249
250
253
254
255
256
257
258
259
260
261
262
263
264
265
274
275
276
277
278
279
280
281
284
285
286
287
288
289
290
291
292
293
294
295
302
303
304
305
306
...
...
...
#define TX_SOURCE_CODE
#include "tx_api.h"
#include "tx_thread.h"
#include "tx_timer.h"
/* ... */
#ifndef TX_NO_TIMER
/* ... */
volatile ULONG _tx_timer_system_clock;
/* ... */
UINT _tx_timer_expired_time_slice;
/* ... */
TX_TIMER_INTERNAL *_tx_timer_list[TX_TIMER_ENTRIES];
/* ... */
TX_TIMER_INTERNAL **_tx_timer_list_start;
TX_TIMER_INTERNAL **_tx_timer_list_end;
/* ... */
TX_TIMER_INTERNAL **_tx_timer_current_ptr;
/* ... */
UINT _tx_timer_expired;
TX_TIMER *_tx_timer_created_ptr;
ULONG _tx_timer_created_count;
TX_TIMER_INTERNAL *_tx_timer_expired_timer_ptr;
#ifndef TX_TIMER_PROCESS_IN_ISR
TX_THREAD _tx_timer_thread;
VOID *_tx_timer_stack_start;
ULONG _tx_timer_stack_size;
UINT _tx_timer_priority;
/* ... */
ULONG _tx_timer_thread_stack_area[(((UINT) TX_TIMER_THREAD_STACK_SIZE)+((sizeof(ULONG))- ((UINT) 1)))/(sizeof(ULONG))];
/* ... */
#else
UINT _tx_timer_processing_active;
/* ... */
#endif
#ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
ULONG _tx_timer_performance_activate_count;
ULONG _tx_timer_performance_reactivate_count;
ULONG _tx_timer_performance_deactivate_count;
ULONG _tx_timer_performance_expiration_count;
/* ... */
ULONG _tx_timer_performance__expiration_adjust_count;
/* ... */
#endif/* ... */
#endif
/* ... */
ULONG _tx_timer_time_slice;
...
...
VOID _tx_timer_initialize(VOID)
{
#ifndef TX_NO_TIMER
#ifndef TX_TIMER_PROCESS_IN_ISR
UINT status;
#endif
#ifndef TX_DISABLE_REDUNDANT_CLEARING
_tx_timer_system_clock = ((ULONG) 0);
_tx_timer_time_slice = ((ULONG) 0);
_tx_timer_expired_time_slice = TX_FALSE;
_tx_timer_expired = TX_FALSE;
_tx_timer_expired_timer_ptr = TX_NULL;
TX_MEMSET(&_tx_timer_list[0], 0, (sizeof(_tx_timer_list)));/* ... */
#endif
_tx_timer_list_start = &_tx_timer_list[0];
_tx_timer_current_ptr = &_tx_timer_list[0];
/* ... */
_tx_timer_list_end = &_tx_timer_list[TX_TIMER_ENTRIES-((ULONG) 1)];
_tx_timer_list_end = TX_TIMER_POINTER_ADD(_tx_timer_list_end, ((ULONG) 1));
#ifndef TX_TIMER_PROCESS_IN_ISR
/* ... */
_tx_timer_stack_start = (VOID *) &_tx_timer_thread_stack_area[0];
_tx_timer_stack_size = ((ULONG) TX_TIMER_THREAD_STACK_SIZE);
_tx_timer_priority = ((UINT) TX_TIMER_THREAD_PRIORITY);
/* ... */
do
{
status = _tx_thread_create(&_tx_timer_thread,
TX_CONST_CHAR_TO_CHAR_POINTER_CONVERT("System Timer Thread"),
_tx_timer_thread_entry,
((ULONG) TX_TIMER_ID),
_tx_timer_stack_start, _tx_timer_stack_size,
_tx_timer_priority, _tx_timer_priority, TX_NO_TIME_SLICE, TX_DONT_START);
#ifdef TX_SAFETY_CRITICAL
if (status != TX_SUCCESS)
{
TX_SAFETY_CRITICAL_EXCEPTION(__FILE__, __LINE__, status);
}if (status != TX_SUCCESS) { ... }
/* ... */#endif
TX_TIMER_INITIALIZE_EXTENSION(status)
...} while (status != TX_SUCCESS);
/* ... */
#else
_tx_timer_processing_active = TX_FALSE;/* ... */
#endif
#ifndef TX_DISABLE_REDUNDANT_CLEARING
_tx_timer_created_ptr = TX_NULL;
_tx_timer_created_count = TX_EMPTY;
#ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
_tx_timer_performance_activate_count = ((ULONG) 0);
_tx_timer_performance_reactivate_count = ((ULONG) 0);
_tx_timer_performance_deactivate_count = ((ULONG) 0);
_tx_timer_performance_expiration_count = ((ULONG) 0);
_tx_timer_performance__expiration_adjust_count = ((ULONG) 0);/* ... */
#endif/* ... */
#endif/* ... */
#endif
}{ ... }