source: rtems/cpukit/score/src/threadget.c @ e3f6d35

4.10
Last change on this file since e3f6d35 was dea1dc20, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/25/11 at 14:17:53

Cosmetics from CVS-HEAD.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  Thread Handler - Object Id to Thread Pointer
3 *
4 *  COPYRIGHT (c) 1989-2011.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/score/apiext.h>
20#include <rtems/score/context.h>
21#include <rtems/score/interr.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/score/priority.h>
25#include <rtems/score/states.h>
26#include <rtems/score/sysstate.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/threadq.h>
29
30
31/**
32 *  This function maps thread IDs to thread control
33 *  blocks.  If ID corresponds to a local thread, then it
34 *  returns the_thread control pointer which maps to ID
35 *  and location is set to OBJECTS_LOCAL.  If the thread ID is
36 *  global and resides on a remote node, then location is set
37 *  to OBJECTS_REMOTE, and the_thread is undefined.
38 *  Otherwise, location is set to OBJECTS_ERROR and
39 *  the_thread is undefined.
40 *
41 *  @note  The performance of many RTEMS services depends upon
42 *         the quick execution of the "good object" path in this
43 *         routine.  If there is a possibility of saving a few
44 *         cycles off the execution time, this routine is worth
45 *         further optimization attention.
46 */
47
48Thread_Control *_Thread_Get (
49  Objects_Id         id,
50  Objects_Locations *location
51)
52{
53  uint32_t             the_api;
54  uint32_t             the_class;
55  Objects_Information **api_information;
56  Objects_Information *information;
57  Thread_Control      *tp = (Thread_Control *) 0;
58
59  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
60    _Thread_Disable_dispatch();
61    *location = OBJECTS_LOCAL;
62    tp = _Thread_Executing;
63    goto done;
64  }
65
66  the_api = _Objects_Get_API( id );
67  if ( !_Objects_Is_api_valid( the_api ) ) {
68    *location = OBJECTS_ERROR;
69    goto done;
70  }
71
72  the_class = _Objects_Get_class( id );
73  if ( the_class != 1 ) {       /* threads are always first class :) */
74    *location = OBJECTS_ERROR;
75    goto done;
76  }
77
78  api_information = _Objects_Information_table[ the_api ];
79  if ( !api_information ) {
80    *location = OBJECTS_ERROR;
81    goto done;
82  }
83
84  information = api_information[ the_class ];
85  if ( !information ) {
86    *location = OBJECTS_ERROR;
87    goto done;
88  }
89
90  tp = (Thread_Control *) _Objects_Get( information, id, location );
91
92done:
93  return tp;
94}
95
Note: See TracBrowser for help on using the repository browser.