summaryrefslogtreecommitdiffstats
path: root/cpukit/score/macros/rtems/score/thread.inl
blob: c520e613adc27e3bb9a6fdc3e152bf617d79bea8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
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
210
211
212
213
214
215
216
217
/*  thread.inl
 *
 *  This file contains the macro implementation of the inlined
 *  routines from the Thread handler.
 *
 *  COPYRIGHT (c) 1989-1997.
 *  On-Line Applications Research Corporation (OAR).
 *  Copyright assigned to U.S. Government, 1994.
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$
 */

#ifndef __THREAD_inl
#define __THREAD_inl

/*PAGE
 *
 *  _Thread_Stop_multitasking
 *
 */

#define _Thread_Stop_multitasking() \
  _Context_Switch( &_Thread_Executing->Registers, &_Thread_BSP_context );

/*PAGE
 *
 *  _Thread_Is_executing
 *
 */

#define _Thread_Is_executing( _the_thread ) \
        ( (_the_thread) == _Thread_Executing )

/*PAGE
 *
 *  _Thread_Is_heir
 *
 */

#define _Thread_Is_heir( _the_thread ) \
        ( (_the_thread) == _Thread_Heir )

/*PAGE
 *
 *  _Thread_Is_executing_also_the_heir
 *
 */

#define _Thread_Is_executing_also_the_heir() \
        ( _Thread_Executing == _Thread_Heir )

/*PAGE
 *
 *  _Thread_Resume
 *
 */

#define _Thread_Resume( _the_thread ) \
        _Thread_Clear_state( (_the_thread), STATES_SUSPENDED )

/*PAGE
 *
 *  _Thread_Unblock
 *
 */

#define _Thread_Unblock( _the_thread ) \
        _Thread_Clear_state( (_the_thread), STATES_BLOCKED );

/*PAGE
 *
 *  _Thread_Restart_self
 *
 */

#define _Thread_Restart_self()  \
  {  \
     if ( _Thread_Executing->fp_context != NULL ) \
       _Context_Restore_fp( &_Thread_Executing->fp_context ); \
     \
    _CPU_Context_Restart_self( &_Thread_Executing->Registers ); \
  }

/*PAGE
 *
 *  _Thread_Calculate_heir
 *
 */

#define _Thread_Calculate_heir() \
 { \
   Priority_Control  highest; \
   \
   _Priority_Get_highest( highest ); \
   \
   _Thread_Heir = (Thread_Control *) _Thread_Ready_chain[ highest ].first; \
  }

/*PAGE
 *
 *  _Thread_Is_allocated_fp
 *
 */

#define _Thread_Is_allocated_fp( _the_thread ) \
        ( (_the_thread) == _Thread_Allocated_fp )

/*PAGE
 *
 *  _Thread_Deallocate_fp
 *
 */

#define _Thread_Deallocate_fp() \
        _Thread_Allocated_fp = NULL

/*PAGE
 *
 *  _Thread_Disable_dispatch
 *
 */

#define _Thread_Disable_dispatch() \
  _Thread_Dispatch_disable_level += 1

/*PAGE
 *
 *  _Thread_Enable_dispatch
 *
 */

#if ( CPU_INLINE_ENABLE_DISPATCH == TRUE )
#define _Thread_Enable_dispatch()  \
      { if ( (--_Thread_Dispatch_disable_level) == 0 ) \
             _Thread_Dispatch();  \
      }
#endif

#if ( CPU_INLINE_ENABLE_DISPATCH == FALSE )
void _Thread_Enable_dispatch( void );
#endif

/*PAGE
 *
 *  _Thread_Unnest_dispatch
 *
 */

#define _Thread_Unnest_dispatch()  \
  _Thread_Dispatch_disable_level -= 1

/*PAGE
 *
 *  _Thread_Is_dispatching_enabled
 *
 */

#define _Thread_Is_dispatching_enabled() \
  ( _Thread_Dispatch_disable_level == 0 )

/*PAGE
 *
 *  _Thread_Is_context_switch_necessary
 *
 */

#define _Thread_Is_context_switch_necessary() \
  ( _Context_Switch_necessary == TRUE )

/*PAGE
 *
 *  _Thread_Dispatch_initialization
 *
 */

#define _Thread_Dispatch_initialization() \
  _Thread_Dispatch_disable_level = 1

/*PAGE
 *
 *  _Thread_Is_null
 *
 */

#define _Thread_Is_null( _the_thread ) \
  ( (_the_thread) == NULL )

/*
 *  _Thread_Is_proxy_blocking
 *
 */
 
#define _Thread_Is_proxy_blocking( _code ) \
  ( (_code) == THREAD_STATUS_PROXY_BLOCKING )

/*
 *  _Thread_Internal_allocate
 *
 */
 
#define _Thread_Internal_allocate() \
  ((Thread_Control *) _Objects_Allocate( &_Thread_Internal_information ))
 
/*
 *  _Thread_Internal_free
 *
 */
 
#define _Thread_Internal_free( _the_task ) \
  _Objects_Free( &_Thread_Internal_information, &(_the_task)->Object )

#endif
/* end of include file */