OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [inline/] [rtems/] [score/] [thread.inl] - Blame information for rev 621

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  thread.inl
2
 *
3
 *  This file contains the macro implementation of the inlined
4
 *  routines from the Thread handler.
5
 *
6
 *  COPYRIGHT (c) 1989-1999.
7
 *  On-Line Applications Research Corporation (OAR).
8
 *
9
 *  The license and distribution terms for this file may be
10
 *  found in the file LICENSE in this distribution or at
11
 *  http://www.OARcorp.com/rtems/license.html.
12
 *
13
 *  $Id: thread.inl,v 1.2 2001-09-27 11:59:34 chris Exp $
14
 */
15
 
16
#ifndef __THREAD_inl
17
#define __THREAD_inl
18
 
19
/*PAGE
20
 *
21
 *  _Thread_Stop_multitasking
22
 *
23
 *  DESCRIPTION:
24
 *
25
 *  This routine halts multitasking and returns control to
26
 *  the "thread" (i.e. the BSP) which initially invoked the
27
 *  routine which initialized the system.
28
 */
29
 
30
RTEMS_INLINE_ROUTINE void _Thread_Stop_multitasking( void )
31
{
32
  _Context_Switch( &_Thread_Executing->Registers, &_Thread_BSP_context );
33
}
34
 
35
/*PAGE
36
 *
37
 *  _Thread_Is_executing
38
 *
39
 *  DESCRIPTION:
40
 *
41
 *  This function returns TRUE if the_thread is the currently executing
42
 *  thread, and FALSE otherwise.
43
 */
44
 
45
RTEMS_INLINE_ROUTINE boolean _Thread_Is_executing (
46
  Thread_Control *the_thread
47
)
48
{
49
  return ( the_thread == _Thread_Executing );
50
}
51
 
52
/*PAGE
53
 *
54
 *  _Thread_Is_heir
55
 *
56
 *  DESCRIPTION:
57
 *
58
 *  This function returns TRUE if the_thread is the heir
59
 *  thread, and FALSE otherwise.
60
 */
61
 
62
RTEMS_INLINE_ROUTINE boolean _Thread_Is_heir (
63
  Thread_Control *the_thread
64
)
65
{
66
  return ( the_thread == _Thread_Heir );
67
}
68
 
69
/*PAGE
70
 *
71
 *  _Thread_Is_executing_also_the_heir
72
 *
73
 *  DESCRIPTION:
74
 *
75
 *  This function returns TRUE if the currently executing thread
76
 *  is also the heir thread, and FALSE otherwise.
77
 */
78
 
79
RTEMS_INLINE_ROUTINE boolean _Thread_Is_executing_also_the_heir( void )
80
{
81
  return ( _Thread_Executing == _Thread_Heir );
82
}
83
 
84
/*PAGE
85
 *
86
 *  _Thread_Unblock
87
 *
88
 *  DESCRIPTION:
89
 *
90
 *  This routine clears any blocking state for the_thread.  It performs
91
 *  any necessary scheduling operations including the selection of
92
 *  a new heir thread.
93
 */
94
 
95
RTEMS_INLINE_ROUTINE void _Thread_Unblock (
96
  Thread_Control *the_thread
97
)
98
{
99
  _Thread_Clear_state( the_thread, STATES_BLOCKED );
100
}
101
 
102
/*PAGE
103
 *
104
 *  _Thread_Restart_self
105
 *
106
 *  DESCRIPTION:
107
 *
108
 *  This routine resets the current context of the calling thread
109
 *  to that of its initial state.
110
 */
111
 
112
RTEMS_INLINE_ROUTINE void _Thread_Restart_self( void )
113
{
114
  if ( _Thread_Executing->fp_context != NULL )
115
    _Context_Restore_fp( &_Thread_Executing->fp_context );
116
 
117
  _CPU_Context_Restart_self( &_Thread_Executing->Registers );
118
}
119
 
120
/*PAGE
121
 *
122
 *  _Thread_Calculate_heir
123
 *
124
 *  DESCRIPTION:
125
 *
126
 *  This function returns a pointer to the highest priority
127
 *  ready thread.
128
 */
129
 
130
RTEMS_INLINE_ROUTINE void _Thread_Calculate_heir( void )
131
{
132
  _Thread_Heir = (Thread_Control *)
133
    _Thread_Ready_chain[ _Priority_Get_highest() ].first;
134
}
135
 
136
/*PAGE
137
 *
138
 *  _Thread_Is_allocated_fp
139
 *
140
 *  DESCRIPTION:
141
 *
142
 *  This function returns TRUE if the floating point context of
143
 *  the_thread is currently loaded in the floating point unit, and
144
 *  FALSE otherwise.
145
 */
146
 
147
RTEMS_INLINE_ROUTINE boolean _Thread_Is_allocated_fp (
148
  Thread_Control *the_thread
149
)
150
{
151
  return ( the_thread == _Thread_Allocated_fp );
152
}
153
 
154
/*PAGE
155
 *
156
 *  _Thread_Deallocate_fp
157
 *
158
 *  DESCRIPTION:
159
 *
160
 *  This routine is invoked when the currently loaded floating
161
 *  point context is now longer associated with an active thread.
162
 */
163
 
164
RTEMS_INLINE_ROUTINE void _Thread_Deallocate_fp( void )
165
{
166
  _Thread_Allocated_fp = NULL;
167
}
168
 
169
/*PAGE
170
 *
171
 *  _Thread_Disable_dispatch
172
 *
173
 *  DESCRIPTION:
174
 *
175
 *  This routine prevents dispatching.
176
 */
177
 
178
RTEMS_INLINE_ROUTINE void _Thread_Disable_dispatch( void )
179
{
180
  _Thread_Dispatch_disable_level += 1;
181
}
182
 
183
/*PAGE
184
 *
185
 *  _Thread_Enable_dispatch
186
 *
187
 *  DESCRIPTION:
188
 *
189
 *  This routine allows dispatching to occur again.  If this is
190
 *  the outer most dispatching critical section, then a dispatching
191
 *  operation will be performed and, if necessary, control of the
192
 *  processor will be transferred to the heir thread.
193
 */
194
 
195
#if ( CPU_INLINE_ENABLE_DISPATCH == TRUE )
196
RTEMS_INLINE_ROUTINE void _Thread_Enable_dispatch()
197
{
198
  if ( (--_Thread_Dispatch_disable_level) == 0 )
199
    _Thread_Dispatch();
200
}
201
#endif
202
 
203
#if ( CPU_INLINE_ENABLE_DISPATCH == FALSE )
204
void _Thread_Enable_dispatch( void );
205
#endif
206
 
207
/*PAGE
208
 *
209
 *  _Thread_Unnest_dispatch
210
 *
211
 *  DESCRIPTION:
212
 *
213
 *  This routine allows dispatching to occur again.  However,
214
 *  no dispatching operation is performed even if this is the outer
215
 *  most dispatching critical section.
216
 */
217
 
218
RTEMS_INLINE_ROUTINE void _Thread_Unnest_dispatch( void )
219
{
220
  _Thread_Dispatch_disable_level -= 1;
221
}
222
 
223
/*PAGE
224
 *
225
 *  _Thread_Is_dispatching_enabled
226
 *
227
 *  DESCRIPTION:
228
 *
229
 *  This function returns TRUE if dispatching is disabled, and FALSE
230
 *  otherwise.
231
 */
232
 
233
RTEMS_INLINE_ROUTINE boolean _Thread_Is_dispatching_enabled( void )
234
{
235
  return ( _Thread_Dispatch_disable_level == 0 );
236
}
237
 
238
/*PAGE
239
 *
240
 *  _Thread_Is_context_switch_necessary
241
 *
242
 *  DESCRIPTION:
243
 *
244
 *  This function returns TRUE if dispatching is disabled, and FALSE
245
 *  otherwise.
246
 */
247
 
248
RTEMS_INLINE_ROUTINE boolean _Thread_Is_context_switch_necessary( void )
249
{
250
  return ( _Context_Switch_necessary );
251
}
252
 
253
/*PAGE
254
 *
255
 *  _Thread_Dispatch_initialization
256
 *
257
 *  DESCRIPTION:
258
 *
259
 *  This routine initializes the thread dispatching subsystem.
260
 */
261
 
262
RTEMS_INLINE_ROUTINE void _Thread_Dispatch_initialization( void )
263
{
264
  _Thread_Dispatch_disable_level = 1;
265
}
266
 
267
/*PAGE
268
 *
269
 *  _Thread_Is_null
270
 *
271
 *  DESCRIPTION:
272
 *
273
 *  This function returns TRUE if the_thread is NULL and FALSE otherwise.
274
 */
275
 
276
RTEMS_INLINE_ROUTINE boolean _Thread_Is_null (
277
  Thread_Control *the_thread
278
)
279
{
280
  return ( the_thread == NULL );
281
}
282
 
283
/*PAGE
284
 *
285
 *  _Thread_Get
286
 *
287
 *  DESCRIPTION:
288
 *
289
 *  This function maps thread IDs to thread control
290
 *  blocks.  If ID corresponds to a local thread, then it
291
 *  returns the_thread control pointer which maps to ID
292
 *  and location is set to OBJECTS_LOCAL.  If the thread ID is
293
 *  global and resides on a remote node, then location is set
294
 *  to OBJECTS_REMOTE, and the_thread is undefined.
295
 *  Otherwise, location is set to OBJECTS_ERROR and
296
 *  the_thread is undefined.
297
 *
298
 *  NOTE:  XXX... This routine may be able to be optimized.
299
 */
300
 
301
RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get (
302
  Objects_Id         id,
303
  Objects_Locations *location
304
)
305
{
306
  Objects_Classes      the_class;
307
  Objects_Information *information;
308
  Thread_Control      *tp = (Thread_Control *) 0;
309
 
310
  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
311
    _Thread_Disable_dispatch();
312
    *location = OBJECTS_LOCAL;
313
    tp = _Thread_Executing;
314
    goto done;
315
  }
316
 
317
  the_class = _Objects_Get_class( id );
318
 
319
  if ( the_class > OBJECTS_CLASSES_LAST ) {
320
    *location = OBJECTS_ERROR;
321
    goto done;
322
  }
323
 
324
  information = _Objects_Information_table[ the_class ];
325
 
326
  if ( !information || !information->is_thread ) {
327
    *location = OBJECTS_ERROR;
328
    goto done;
329
  }
330
 
331
  tp = (Thread_Control *) _Objects_Get( information, id, location );
332
 
333
done:
334
  return tp;
335
}
336
 
337
 
338
/*
339
 *  _Thread_Is_proxy_blocking
340
 *
341
 *  DESCRIPTION:
342
 *
343
 *  This function returns TRUE if the status code is equal to the
344
 *  status which indicates that a proxy is blocking, and FALSE otherwise.
345
 */
346
 
347
RTEMS_INLINE_ROUTINE boolean _Thread_Is_proxy_blocking (
348
  unsigned32 code
349
)
350
{
351
  return (code == THREAD_STATUS_PROXY_BLOCKING);
352
}
353
 
354
/*PAGE
355
 *
356
 *  _Thread_Internal_allocate
357
 *
358
 *  DESCRIPTION:
359
 *
360
 *  This routine allocates an internal thread.
361
 */
362
 
363
RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Internal_allocate( void )
364
{
365
  return (Thread_Control *) _Objects_Allocate( &_Thread_Internal_information );
366
}
367
 
368
/*PAGE
369
 *
370
 *  _Thread_Internal_free
371
 *
372
 *  DESCRIPTION:
373
 *
374
 *  This routine frees an internal thread.
375
 */
376
 
377
RTEMS_INLINE_ROUTINE void _Thread_Internal_free (
378
  Thread_Control *the_task
379
)
380
{
381
  _Objects_Free( &_Thread_Internal_information, &the_task->Object );
382
}
383
 
384
#endif
385
/* end of include file */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.