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

5
Last change on this file since 1506658c was 1041de1, checked in by Sebastian Huber <sebastian.huber@…>, on 04/20/15 at 07:45:10

score: Add _Thread_Get_interrupt_disable()

Remove _Thread_Acquire() and _Thread_Acquire_for_executing(). Add
utility functions for the default thread lock. Use the default thread
lock for the RTEMS events. There is no need to disable thread
dispatching and a Giant acquire in _Event_Timeout() since this was
already done by the caller.

Update #2273.

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