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
91
92
93
94
95
96
97
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
127
128
129
130
131
132
133
134
135
136
138
139
140
143
144
145
146
152
153
154
155
156
159
160
161
162
163
164
165
166
173
174
175
176
177
178
179
188
189
190
...
...
...
#define TX_SOURCE_CODE
#ifndef TX_NO_TIMER
#include "tx_api.h"
#include "tx_timer.h"
#include "tx_thread.h"
#include "tx_trace.h"
...
VOID _tx_thread_time_slice(VOID)
{
TX_INTERRUPT_SAVE_AREA
TX_THREAD *thread_ptr;
#ifdef TX_ENABLE_STACK_CHECKING
TX_THREAD *next_thread_ptr;
#endif
#ifdef TX_ENABLE_EVENT_TRACE
ULONG system_state;
UINT preempt_disable;/* ... */
#endif
TX_THREAD_GET_CURRENT(thread_ptr)
#ifdef TX_ENABLE_STACK_CHECKING
TX_THREAD_STACK_CHECK(thread_ptr)
next_thread_ptr = TX_NULL;/* ... */
#endif
TX_DISABLE
_tx_timer_expired_time_slice = TX_FALSE;
if (thread_ptr != TX_NULL)
{
if (thread_ptr -> tx_thread_state == TX_READY)
{
thread_ptr -> tx_thread_time_slice = thread_ptr -> tx_thread_new_time_slice;
_tx_timer_time_slice = thread_ptr -> tx_thread_time_slice;
/* ... */
if (thread_ptr -> tx_thread_ready_next != thread_ptr)
{
if (thread_ptr -> tx_thread_priority == thread_ptr -> tx_thread_preempt_threshold)
{
/* ... */
_tx_thread_priority_list[thread_ptr -> tx_thread_priority] = thread_ptr -> tx_thread_ready_next;
/* ... */
_tx_thread_execute_ptr = _tx_thread_priority_list[_tx_thread_highest_priority];
#ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO
thread_ptr -> tx_thread_performance_time_slice_count++;
_tx_thread_performance_time_slice_count++;/* ... */
#endif
#ifdef TX_ENABLE_STACK_CHECKING
next_thread_ptr = _tx_thread_execute_ptr;/* ... */
#endif
}if (thread_ptr -> tx_thread_priority == thread_ptr -> tx_thread_preempt_threshold) { ... }
}if (thread_ptr -> tx_thread_ready_next != thread_ptr) { ... }
}if (thread_ptr -> tx_thread_state == TX_READY) { ... }
}if (thread_ptr != TX_NULL) { ... }
#ifdef TX_ENABLE_EVENT_TRACE
system_state = TX_THREAD_GET_SYSTEM_STATE();
preempt_disable = _tx_thread_preempt_disable;
TX_TRACE_IN_LINE_INSERT(TX_TRACE_TIME_SLICE, _tx_thread_execute_ptr, system_state, preempt_disable, TX_POINTER_TO_ULONG_CONVERT(&thread_ptr), TX_TRACE_INTERNAL_EVENTS)/* ... */
#endif
TX_RESTORE
#ifdef TX_ENABLE_STACK_CHECKING
if (next_thread_ptr != TX_NULL)
{
TX_THREAD_STACK_CHECK(next_thread_ptr)
}if (next_thread_ptr != TX_NULL) { ... }
/* ... */#endif
}{ ... }
...#endif/* ... */