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
94
95
96
97
98
99
100
103
104
105
106
107
108
109
110
111
112
114
115
116
117
118
119
120
121
122
123
124
126
127
128
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
164
165
166
168
169
170
171
...
...
...
#define TX_SOURCE_CODE
#include "tx_api.h"
#include "tx_trace.h"
#include "tx_thread.h"
#ifndef TX_NO_TIMER
#include "tx_timer.h"
#endif
...
...
VOID _tx_thread_relinquish(VOID)
{
TX_INTERRUPT_SAVE_AREA
UINT priority;
TX_THREAD *thread_ptr;
TX_THREAD_GET_CURRENT(thread_ptr)
#ifdef TX_ENABLE_STACK_CHECKING
TX_THREAD_STACK_CHECK(thread_ptr)/* ... */
#endif
TX_DISABLE
#ifndef TX_NO_TIMER
_tx_timer_time_slice = thread_ptr -> tx_thread_new_time_slice;/* ... */
#endif
priority = thread_ptr -> tx_thread_priority;
if (thread_ptr -> tx_thread_ready_next != thread_ptr)
{
/* ... */
_tx_thread_priority_list[priority] = thread_ptr -> tx_thread_ready_next;
_tx_thread_execute_ptr = thread_ptr -> tx_thread_ready_next;
}if (thread_ptr -> tx_thread_ready_next != thread_ptr) { ... }
if (_tx_thread_highest_priority < priority)
{
/* ... */
_tx_thread_execute_ptr = _tx_thread_priority_list[_tx_thread_highest_priority];
/* ... */
}if (_tx_thread_highest_priority < priority) { ... }
TX_TRACE_IN_LINE_INSERT(TX_TRACE_THREAD_RELINQUISH, &thread_ptr, TX_POINTER_TO_ULONG_CONVERT(_tx_thread_execute_ptr), 0, 0, TX_TRACE_THREAD_EVENTS)
TX_EL_THREAD_RELINQUISH_INSERT
TX_RESTORE
if (_tx_thread_execute_ptr != thread_ptr)
{
#ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO
thread_ptr -> tx_thread_performance_relinquish_count++;
_tx_thread_performance_relinquish_count++;
_tx_thread_performance_non_idle_return_count++;/* ... */
#endif
#ifdef TX_ENABLE_STACK_CHECKING
thread_ptr = _tx_thread_execute_ptr;
TX_THREAD_STACK_CHECK(thread_ptr)/* ... */
#endif
/* ... */
_tx_thread_system_return();
}if (_tx_thread_execute_ptr != thread_ptr) { ... }
}{ ... }