source: rtems/cpukit/score/src/threadget.c @ 25f5730f

4.115
Last change on this file since 25f5730f was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[d4d7899]1/**
2 * @file
3 *
4 * @brief Maps Thread IDs to TCB Pointer
[78dabb69]5 *
[d4d7899]6 * @ingroup ScoreThread
7 */
8
9/*
[b1e13f4]10 *  COPYRIGHT (c) 1989-2011.
[78dabb69]11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
[dcf3687]14 *  found in the file LICENSE in this distribution or at
[c499856]15 *  http://www.rtems.org/license/LICENSE.
[78dabb69]16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
[5618c37a]22#include <rtems/score/threadimpl.h>
[78dabb69]23
24Thread_Control *_Thread_Get (
25  Objects_Id         id,
26  Objects_Locations *location
27)
28{
29  uint32_t             the_api;
30  uint32_t             the_class;
[d8d373a]31  Objects_Information **api_information;
[78dabb69]32  Objects_Information *information;
33  Thread_Control      *tp = (Thread_Control *) 0;
[28352fae]34
[78dabb69]35  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
36    _Thread_Disable_dispatch();
37    *location = OBJECTS_LOCAL;
38    tp = _Thread_Executing;
39    goto done;
40  }
[28352fae]41
[78dabb69]42  the_api = _Objects_Get_API( id );
[52e70cf]43  if ( !_Objects_Is_api_valid( the_api ) ) {
[78dabb69]44    *location = OBJECTS_ERROR;
45    goto done;
46  }
[28352fae]47
[78dabb69]48  the_class = _Objects_Get_class( id );
49  if ( the_class != 1 ) {       /* threads are always first class :) */
50    *location = OBJECTS_ERROR;
51    goto done;
52  }
[28352fae]53
[d8d373a]54  api_information = _Objects_Information_table[ the_api ];
[56e135a1]55  /*
[b1e13f4]56   *  There is no way for this to happen if POSIX is enabled.  But there
57   *  is actually a test case in sp43 for this which trips it whether or
58   *  not POSIX is enabled.  So in the interest of safety, this is left
59   *  on in all configurations.
[dacdda30]60   */
[b1e13f4]61  if ( !api_information ) {
62    *location = OBJECTS_ERROR;
63    goto done;
64  }
[d8d373a]65
66  information = api_information[ the_class ];
[78dabb69]67  if ( !information ) {
68    *location = OBJECTS_ERROR;
69    goto done;
70  }
[28352fae]71
[78dabb69]72  tp = (Thread_Control *) _Objects_Get( information, id, location );
[28352fae]73
[78dabb69]74done:
75  return tp;
76}
77
Note: See TracBrowser for help on using the repository browser.