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
121
122
123
124
125
126
127
128
129
130
131
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
172
173
174
175
176
177
178
179
180
181
182
183
185
186
187
188
189
190
191
192
193
194
196
197
198
199
200
201
202
203
204
205
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
241
242
243
244
245
...
...
...
#define TX_SOURCE_CODE
#include "tx_api.h"
#include "tx_trace.h"
#include "tx_thread.h"
#include "tx_mutex.h"
...
...
UINT _tx_mutex_delete(TX_MUTEX *mutex_ptr)
{
TX_INTERRUPT_SAVE_AREA
TX_THREAD *thread_ptr;
TX_THREAD *next_thread;
TX_THREAD *owner_thread;
UINT suspended_count;
TX_MUTEX *next_mutex;
TX_MUTEX *previous_mutex;
#ifdef TX_MISRA_ENABLE
UINT status;
#endif
TX_DISABLE
TX_TRACE_IN_LINE_INSERT(TX_TRACE_MUTEX_DELETE, mutex_ptr, TX_POINTER_TO_ULONG_CONVERT(&thread_ptr), 0, 0, TX_TRACE_MUTEX_EVENTS)
TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
TX_TRACE_OBJECT_UNREGISTER(mutex_ptr)
TX_EL_MUTEX_DELETE_INSERT
mutex_ptr -> tx_mutex_id = TX_CLEAR_ID;
_tx_mutex_created_count--;
if (_tx_mutex_created_count == TX_EMPTY)
{
_tx_mutex_created_ptr = TX_NULL;
}if (_tx_mutex_created_count == TX_EMPTY) { ... }
else
{
next_mutex = mutex_ptr -> tx_mutex_created_next;
previous_mutex = mutex_ptr -> tx_mutex_created_previous;
next_mutex -> tx_mutex_created_previous = previous_mutex;
previous_mutex -> tx_mutex_created_next = next_mutex;
if (_tx_mutex_created_ptr == mutex_ptr)
{
_tx_mutex_created_ptr = next_mutex;
}if (_tx_mutex_created_ptr == mutex_ptr) { ... }
}else { ... }
_tx_thread_preempt_disable++;
thread_ptr = mutex_ptr -> tx_mutex_suspension_list;
mutex_ptr -> tx_mutex_suspension_list = TX_NULL;
suspended_count = mutex_ptr -> tx_mutex_suspended_count;
mutex_ptr -> tx_mutex_suspended_count = TX_NO_SUSPENSIONS;
owner_thread = mutex_ptr -> tx_mutex_owner;
if (owner_thread != TX_NULL)
{
mutex_ptr -> tx_mutex_ownership_count = ((UINT) 1);
TX_RESTORE
#ifdef TX_MISRA_ENABLE
do
{
status = _tx_mutex_put(mutex_ptr);
...} while (status != TX_SUCCESS);/* ... */
#else
_tx_mutex_put(mutex_ptr);
#endif
TX_DISABLE
}if (owner_thread != TX_NULL) { ... }
TX_RESTORE
/* ... */
while (suspended_count != ((ULONG) 0))
{
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 != ((ULONG) 0)) { ... }
TX_MUTEX_DELETE_PORT_COMPLETION(mutex_ptr)
TX_DISABLE
_tx_thread_preempt_disable--;
TX_RESTORE
_tx_thread_system_preempt_check();
return(TX_SUCCESS);
}{ ... }