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

4.115
Last change on this file since dcf3687 was dcf3687, checked in by Joel Sherrill <joel.sherrill@…>, on 01/28/11 at 20:24:54

2011-01-28 Joel Sherrill <joel.sherrilL@…>

  • include/rtems/bspIo.h, include/rtems/concat.h, include/rtems/irq.h, score/cpu/i386/rtems/score/idtr.h, score/cpu/powerpc/rtems/powerpc/registers.h, score/src/objectidtoname.c, score/src/schedulerpriorityblock.c, score/src/schedulerpriorityschedule.c, score/src/schedulerpriorityunblock.c, score/src/schedulerpriorityyield.c, score/src/thread.c, score/src/threadchangepriority.c, score/src/threadclearstate.c, score/src/threadclose.c, score/src/threadcreateidle.c, score/src/threaddelayended.c, score/src/threaddispatch.c, score/src/threadget.c, score/src/threadhandler.c, score/src/threadinitialize.c, score/src/threadloadenv.c, score/src/threadready.c, score/src/threadreset.c, score/src/threadrestart.c, score/src/threadresume.c, score/src/threadsetpriority.c, score/src/threadsetstate.c, score/src/threadsettransient.c, score/src/threadstackallocate.c, score/src/threadstackfree.c, score/src/threadstart.c, score/src/threadstartmultitasking.c, score/src/threadsuspend.c, score/src/threadtickletimeslice.c, score/src/threadyieldprocessor.c: Fix typo where license said found in found in.
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  Thread Handler - Object Id to Thread Pointer
3 *
4 *  COPYRIGHT (c) 1989-2010.
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 */
47Thread_Control *_Thread_Get (
48  Objects_Id         id,
49  Objects_Locations *location
50)
51{
52  uint32_t             the_api;
53  uint32_t             the_class;
54  Objects_Information **api_information;
55  Objects_Information *information;
56  Thread_Control      *tp = (Thread_Control *) 0;
57
58  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
59    _Thread_Disable_dispatch();
60    *location = OBJECTS_LOCAL;
61    tp = _Thread_Executing;
62    goto done;
63  }
64
65  the_api = _Objects_Get_API( id );
66  if ( !_Objects_Is_api_valid( the_api ) ) {
67    *location = OBJECTS_ERROR;
68    goto done;
69  }
70
71  the_class = _Objects_Get_class( id );
72  if ( the_class != 1 ) {       /* threads are always first class :) */
73    *location = OBJECTS_ERROR;
74    goto done;
75  }
76
77  api_information = _Objects_Information_table[ the_api ];
78  /*
79   *  There is no way for this to happen if POSIX is enabled.
80   */
81  #if !defined(RTEMS_POSIX_API)
82    if ( !api_information ) {
83      *location = OBJECTS_ERROR;
84      goto done;
85    }
86  #endif
87
88  information = api_information[ the_class ];
89  if ( !information ) {
90    *location = OBJECTS_ERROR;
91    goto done;
92  }
93
94  tp = (Thread_Control *) _Objects_Get( information, id, location );
95
96done:
97  return tp;
98}
99
Note: See TracBrowser for help on using the repository browser.