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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
130
131
132
133
134
135
136
137
138
139
140
141
142
143
157
158
159
160
161
162
163
164
165
166
167
168
170
171
172
173
174
175
176
177
178
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
206
207
208
209
210
211
212
216
217
220
221
222
223
226
227
228
229
235
236
237
240
241
242
243
244
245
246
249
250
251
252
253
254
255
264
265
266
269
270
271
272
273
276
277
278
279
286
287
288
291
292
293
294
295
296
297
298
299
305
306
307
308
309
310
311
312
...
...
...
#define TX_SOURCE_CODE
#include "tx_api.h"
#include "tx_trace.h"
#include "tx_thread.h"
#include "tx_timer.h"
...
...
UINT _tx_thread_terminate(TX_THREAD *thread_ptr)
{
TX_INTERRUPT_SAVE_AREA
VOID (*suspend_cleanup)(struct TX_THREAD_STRUCT *suspend_thread_ptr, ULONG suspension_sequence);
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
VOID (*entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT id);
#endif
UINT status;
ULONG suspension_sequence;
status = TX_SUCCESS;
TX_DISABLE
_tx_timer_system_deactivate(&thread_ptr -> tx_thread_timer);
TX_TRACE_IN_LINE_INSERT(TX_TRACE_THREAD_TERMINATE, thread_ptr, thread_ptr -> tx_thread_state, TX_POINTER_TO_ULONG_CONVERT(&suspend_cleanup), 0, TX_TRACE_THREAD_EVENTS)
TX_EL_THREAD_TERMINATE_INSERT
if (thread_ptr -> tx_thread_state == TX_TERMINATED)
{
TX_RESTORE
status = TX_SUCCESS;
}if (thread_ptr -> tx_thread_state == TX_TERMINATED) { ... }
else if (thread_ptr -> tx_thread_state != TX_COMPLETED)
{
_tx_thread_preempt_disable++;
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
entry_exit_notify = thread_ptr -> tx_thread_entry_exit_notify;/* ... */
#endif
if (thread_ptr -> tx_thread_state == TX_READY)
{
thread_ptr -> tx_thread_state = TX_TERMINATED;
TX_THREAD_STATE_CHANGE(thread_ptr, TX_TERMINATED)
#ifdef TX_NOT_INTERRUPTABLE
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
if (entry_exit_notify != TX_NULL)
{
(entry_exit_notify)(thread_ptr, TX_THREAD_EXIT);
}if (entry_exit_notify != TX_NULL) { ... }
/* ... */#endif
_tx_thread_system_ni_suspend(thread_ptr, ((ULONG) 0));/* ... */
#else
thread_ptr -> tx_thread_suspending = TX_TRUE;
thread_ptr -> tx_thread_timer.tx_timer_internal_remaining_ticks = ((ULONG) 0);
_tx_thread_preempt_disable++;
/* ... */
TX_RESTORE
TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
if (entry_exit_notify != TX_NULL)
{
(entry_exit_notify)(thread_ptr, TX_THREAD_EXIT);
}if (entry_exit_notify != TX_NULL) { ... }
/* ... */#endif
_tx_thread_system_suspend(thread_ptr);
TX_DISABLE/* ... */
#endif
}if (thread_ptr -> tx_thread_state == TX_READY) { ... }
else
{
thread_ptr -> tx_thread_state = TX_TERMINATED;
TX_THREAD_STATE_CHANGE(thread_ptr, TX_TERMINATED)
/* ... */
thread_ptr -> tx_thread_suspending = TX_TRUE;
suspend_cleanup = thread_ptr -> tx_thread_suspend_cleanup;
#ifndef TX_NOT_INTERRUPTABLE
/* ... */
suspension_sequence = thread_ptr -> tx_thread_suspension_sequence;/* ... */
#else
suspension_sequence = ((ULONG) 0);/* ... */
#endif
#ifndef TX_NOT_INTERRUPTABLE
TX_RESTORE/* ... */
#endif
if (suspend_cleanup != TX_NULL)
{
(suspend_cleanup)(thread_ptr, suspension_sequence);
}if (suspend_cleanup != TX_NULL) { ... }
#ifndef TX_NOT_INTERRUPTABLE
TX_DISABLE/* ... */
#endif
thread_ptr -> tx_thread_suspending = TX_FALSE;
#ifndef TX_NOT_INTERRUPTABLE
TX_RESTORE/* ... */
#endif
TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
if (entry_exit_notify != TX_NULL)
{
(entry_exit_notify)(thread_ptr, TX_THREAD_EXIT);
}if (entry_exit_notify != TX_NULL) { ... }
/* ... */#endif
#ifndef TX_NOT_INTERRUPTABLE
TX_DISABLE/* ... */
#endif
}else { ... }
#ifndef TX_NOT_INTERRUPTABLE
TX_RESTORE/* ... */
#endif
if (_tx_thread_mutex_release != TX_NULL)
{
/* ... */
(_tx_thread_mutex_release)(thread_ptr);
}if (_tx_thread_mutex_release != TX_NULL) { ... }
#ifndef TX_NOT_INTERRUPTABLE
TX_DISABLE/* ... */
#endif
_tx_thread_preempt_disable--;
TX_RESTORE
}else if (thread_ptr -> tx_thread_state != TX_COMPLETED) { ... }
else
{
TX_RESTORE
}else { ... }
_tx_thread_system_preempt_check();
return(status);
}{ ... }