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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
147
148
149
150
156
157
158
159
160
161
164
165
166
167
168
169
170
171
172
181
182
183
184
185
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
235
236
237
238
239
240
241
244
245
246
247
253
254
255
256
257
258
259
260
261
262
263
264
265
266
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
304
305
306
307
308
309
310
311
312
314
315
316
317
318
319
323
324
325
326
327
328
329
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
357
358
359
360
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
399
400
401
402
403
404
405
406
407
408
409
410
416
417
418
419
420
421
422
423
424
425
426
427
428
...
...
...
#define TX_SOURCE_CODE
#include "tx_api.h"
#include "tx_trace.h"
#include "tx_thread.h"
#include "tx_queue.h"
...
...
UINT _tx_queue_send(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option)
{
TX_INTERRUPT_SAVE_AREA
TX_THREAD *thread_ptr;
ULONG *source;
ULONG *destination;
UINT size;
UINT suspended_count;
TX_THREAD *next_thread;
TX_THREAD *previous_thread;
UINT status;
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
VOID (*queue_send_notify)(struct TX_QUEUE_STRUCT *notify_queue_ptr);
#endif
status = TX_SUCCESS;
TX_DISABLE
#ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO
_tx_queue_performance_messages_sent_count++;
queue_ptr -> tx_queue_performance_messages_sent_count++;/* ... */
#endif
TX_TRACE_IN_LINE_INSERT(TX_TRACE_QUEUE_SEND, queue_ptr, TX_POINTER_TO_ULONG_CONVERT(source_ptr), wait_option, queue_ptr -> tx_queue_enqueued, TX_TRACE_QUEUE_EVENTS)
TX_EL_QUEUE_SEND_INSERT
suspended_count = queue_ptr -> tx_queue_suspended_count;
if (queue_ptr -> tx_queue_available_storage != TX_NO_MESSAGES)
{
if (suspended_count == TX_NO_SUSPENSIONS)
{
queue_ptr -> tx_queue_available_storage--;
queue_ptr -> tx_queue_enqueued++;
source = TX_VOID_TO_ULONG_POINTER_CONVERT(source_ptr);
destination = queue_ptr -> tx_queue_write;
size = queue_ptr -> tx_queue_message_size;
/* ... */
TX_QUEUE_MESSAGE_COPY(source, destination, size)
if (destination == queue_ptr -> tx_queue_end)
{
destination = queue_ptr -> tx_queue_start;
}if (destination == queue_ptr -> tx_queue_end) { ... }
queue_ptr -> tx_queue_write = destination;
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
queue_send_notify = queue_ptr -> tx_queue_send_notify;/* ... */
#endif
TX_RESTORE
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
if (queue_send_notify != TX_NULL)
{
(queue_send_notify)(queue_ptr);
}if (queue_send_notify != TX_NULL) { ... }
/* ... */#endif
}if (suspended_count == TX_NO_SUSPENSIONS) { ... }
else
{
/* ... */
thread_ptr = queue_ptr -> tx_queue_suspension_list;
suspended_count--;
if (suspended_count == TX_NO_SUSPENSIONS)
{
queue_ptr -> tx_queue_suspension_list = TX_NULL;
}if (suspended_count == TX_NO_SUSPENSIONS) { ... }
else
{
queue_ptr -> tx_queue_suspension_list = thread_ptr -> tx_thread_suspended_next;
next_thread = thread_ptr -> tx_thread_suspended_next;
queue_ptr -> tx_queue_suspension_list = next_thread;
previous_thread = thread_ptr -> tx_thread_suspended_previous;
next_thread -> tx_thread_suspended_previous = previous_thread;
previous_thread -> tx_thread_suspended_next = next_thread;
}else { ... }
queue_ptr -> tx_queue_suspended_count = suspended_count;
thread_ptr -> tx_thread_suspend_cleanup = TX_NULL;
source = TX_VOID_TO_ULONG_POINTER_CONVERT(source_ptr);
destination = TX_VOID_TO_ULONG_POINTER_CONVERT(thread_ptr -> tx_thread_additional_suspend_info);
size = queue_ptr -> tx_queue_message_size;
/* ... */
TX_QUEUE_MESSAGE_COPY(source, destination, size)
thread_ptr -> tx_thread_suspend_status = TX_SUCCESS;
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
queue_send_notify = queue_ptr -> tx_queue_send_notify;/* ... */
#endif
#ifdef TX_NOT_INTERRUPTABLE
_tx_thread_system_ni_resume(thread_ptr);
TX_RESTORE/* ... */
#else
_tx_thread_preempt_disable++;
TX_RESTORE
_tx_thread_system_resume(thread_ptr);/* ... */
#endif
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
if (queue_send_notify != TX_NULL)
{
(queue_send_notify)(queue_ptr);
}if (queue_send_notify != TX_NULL) { ... }
/* ... */#endif
}else { ... }
}if (queue_ptr -> tx_queue_available_storage != TX_NO_MESSAGES) { ... }
else if (wait_option != TX_NO_WAIT)
{
if (_tx_thread_preempt_disable != ((UINT) 0))
{
TX_RESTORE
status = TX_QUEUE_FULL;
}if (_tx_thread_preempt_disable != ((UINT) 0)) { ... }
else
{
#ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO
_tx_queue_performance_full_suspension_count++;
queue_ptr -> tx_queue_performance_full_suspension_count++;/* ... */
#endif
TX_THREAD_GET_CURRENT(thread_ptr)
thread_ptr -> tx_thread_suspend_cleanup = &(_tx_queue_cleanup);
/* ... */
thread_ptr -> tx_thread_suspend_control_block = (VOID *) queue_ptr;
thread_ptr -> tx_thread_additional_suspend_info = (VOID *) source_ptr;
thread_ptr -> tx_thread_suspend_option = TX_FALSE;
#ifndef TX_NOT_INTERRUPTABLE
/* ... */
thread_ptr -> tx_thread_suspension_sequence++;/* ... */
#endif
if (suspended_count == TX_NO_SUSPENSIONS)
{
/* ... */
queue_ptr -> tx_queue_suspension_list = thread_ptr;
thread_ptr -> tx_thread_suspended_next = thread_ptr;
thread_ptr -> tx_thread_suspended_previous = thread_ptr;
}if (suspended_count == TX_NO_SUSPENSIONS) { ... }
else
{
next_thread = queue_ptr -> tx_queue_suspension_list;
thread_ptr -> tx_thread_suspended_next = next_thread;
previous_thread = next_thread -> tx_thread_suspended_previous;
thread_ptr -> tx_thread_suspended_previous = previous_thread;
previous_thread -> tx_thread_suspended_next = thread_ptr;
next_thread -> tx_thread_suspended_previous = thread_ptr;
}else { ... }
queue_ptr -> tx_queue_suspended_count = suspended_count + ((UINT) 1);
thread_ptr -> tx_thread_state = TX_QUEUE_SUSP;
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
queue_send_notify = queue_ptr -> tx_queue_send_notify;/* ... */
#endif
#ifdef TX_NOT_INTERRUPTABLE
_tx_thread_system_ni_suspend(thread_ptr, wait_option);
TX_RESTORE/* ... */
#else
thread_ptr -> tx_thread_suspending = TX_TRUE;
thread_ptr -> tx_thread_timer.tx_timer_internal_remaining_ticks = wait_option;
_tx_thread_preempt_disable++;
TX_RESTORE
_tx_thread_system_suspend(thread_ptr);/* ... */
#endif
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
if (thread_ptr -> tx_thread_suspend_status == TX_SUCCESS)
{
if (queue_send_notify != TX_NULL)
{
(queue_send_notify)(queue_ptr);
}if (queue_send_notify != TX_NULL) { ... }
}if (thread_ptr -> tx_thread_suspend_status == TX_SUCCESS) { ... }
/* ... */#endif
status = thread_ptr -> tx_thread_suspend_status;
}else { ... }
}else if (wait_option != TX_NO_WAIT) { ... }
else
{
#ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO
queue_ptr -> tx_queue_performance_full_error_count++;
_tx_queue_performance_full_error_count++;/* ... */
#endif
TX_RESTORE
status = TX_QUEUE_FULL;
}else { ... }
return(status);
}{ ... }