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
117
118
119
120
121
122
123
124
125
126
127
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
149
150
151
152
153
154
155
156
157
158
160
161
162
163
164
165
166
167
168
169
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
...
...
...
#define TX_SOURCE_CODE
#include "tx_api.h"
#include "tx_trace.h"
#include "tx_thread.h"
#include "tx_semaphore.h"
...
...
UINT _tx_semaphore_delete(TX_SEMAPHORE *semaphore_ptr)
{
TX_INTERRUPT_SAVE_AREA
TX_THREAD *thread_ptr;
TX_THREAD *next_thread;
UINT suspended_count;
TX_SEMAPHORE *next_semaphore;
TX_SEMAPHORE *previous_semaphore;
TX_DISABLE
TX_TRACE_IN_LINE_INSERT(TX_TRACE_SEMAPHORE_DELETE, semaphore_ptr, TX_POINTER_TO_ULONG_CONVERT(&thread_ptr), 0, 0, TX_TRACE_SEMAPHORE_EVENTS)
TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
TX_TRACE_OBJECT_UNREGISTER(semaphore_ptr)
TX_EL_SEMAPHORE_DELETE_INSERT
semaphore_ptr -> tx_semaphore_id = TX_CLEAR_ID;
_tx_semaphore_created_count--;
if (_tx_semaphore_created_count == TX_EMPTY)
{
_tx_semaphore_created_ptr = TX_NULL;
}if (_tx_semaphore_created_count == TX_EMPTY) { ... }
else
{
next_semaphore = semaphore_ptr -> tx_semaphore_created_next;
previous_semaphore = semaphore_ptr -> tx_semaphore_created_previous;
next_semaphore -> tx_semaphore_created_previous = previous_semaphore;
previous_semaphore -> tx_semaphore_created_next = next_semaphore;
if (_tx_semaphore_created_ptr == semaphore_ptr)
{
_tx_semaphore_created_ptr = next_semaphore;
}if (_tx_semaphore_created_ptr == semaphore_ptr) { ... }
}else { ... }
_tx_thread_preempt_disable++;
thread_ptr = semaphore_ptr -> tx_semaphore_suspension_list;
semaphore_ptr -> tx_semaphore_suspension_list = TX_NULL;
suspended_count = semaphore_ptr -> tx_semaphore_suspended_count;
semaphore_ptr -> tx_semaphore_suspended_count = TX_NO_SUSPENSIONS;
TX_RESTORE
/* ... */
while (suspended_count != TX_NO_SUSPENSIONS)
{
suspended_count--;
TX_DISABLE
/* ... */
thread_ptr -> tx_thread_suspend_cleanup = TX_NULL;
thread_ptr -> tx_thread_suspend_status = TX_DELETED;
next_thread = thread_ptr -> tx_thread_suspended_next;
#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
thread_ptr = next_thread;
}while (suspended_count != TX_NO_SUSPENSIONS) { ... }
TX_SEMAPHORE_DELETE_PORT_COMPLETION(semaphore_ptr)
TX_DISABLE
_tx_thread_preempt_disable--;
TX_RESTORE
_tx_thread_system_preempt_check();
return(TX_SUCCESS);
}{ ... }