source: rtems/cpukit/score/src/objectmp.c @ dd687d97

4.104.114.84.95
Last change on this file since dd687d97 was dd687d97, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:56:05

2003-09-04 Joel Sherrill <joel@…>

  • include/rtems/debug.h, include/rtems/seterr.h, include/rtems/system.h, include/rtems/score/address.h, include/rtems/score/apiext.h, include/rtems/score/apimutex.h, include/rtems/score/bitfield.h, include/rtems/score/chain.h, include/rtems/score/context.h, include/rtems/score/copyrt.h, include/rtems/score/coremsg.h, include/rtems/score/coremutex.h, include/rtems/score/coresem.h, include/rtems/score/heap.h, include/rtems/score/interr.h, include/rtems/score/isr.h, include/rtems/score/mpci.h, include/rtems/score/mppkt.h, include/rtems/score/object.h, include/rtems/score/objectmp.h, include/rtems/score/priority.h, include/rtems/score/stack.h, include/rtems/score/states.h, include/rtems/score/sysstate.h, include/rtems/score/thread.h, include/rtems/score/threadmp.h, include/rtems/score/threadq.h, include/rtems/score/tod.h, include/rtems/score/tqdata.h, include/rtems/score/userext.h, include/rtems/score/watchdog.h, include/rtems/score/wkspace.h, inline/rtems/score/address.inl, inline/rtems/score/chain.inl, inline/rtems/score/coremsg.inl, inline/rtems/score/coremutex.inl, inline/rtems/score/coresem.inl, inline/rtems/score/heap.inl, inline/rtems/score/isr.inl, inline/rtems/score/mppkt.inl, inline/rtems/score/object.inl, inline/rtems/score/objectmp.inl, inline/rtems/score/priority.inl, inline/rtems/score/stack.inl, inline/rtems/score/states.inl, inline/rtems/score/sysstate.inl, inline/rtems/score/thread.inl, inline/rtems/score/threadmp.inl, inline/rtems/score/tod.inl, inline/rtems/score/tqdata.inl, inline/rtems/score/userext.inl, inline/rtems/score/watchdog.inl, inline/rtems/score/wkspace.inl, macros/rtems/score/address.inl, macros/rtems/score/chain.inl, macros/rtems/score/coremsg.inl, macros/rtems/score/coremutex.inl, macros/rtems/score/coresem.inl, macros/rtems/score/heap.inl, macros/rtems/score/isr.inl, macros/rtems/score/mppkt.inl, macros/rtems/score/object.inl, macros/rtems/score/objectmp.inl, macros/rtems/score/priority.inl, macros/rtems/score/stack.inl, macros/rtems/score/states.inl, macros/rtems/score/sysstate.inl, macros/rtems/score/thread.inl, macros/rtems/score/threadmp.inl, macros/rtems/score/tod.inl, macros/rtems/score/tqdata.inl, macros/rtems/score/userext.inl, macros/rtems/score/watchdog.inl, macros/rtems/score/wkspace.inl, src/apiext.c, src/chain.c, src/coremsg.c, src/coremsgbroadcast.c, src/coremsgclose.c, src/coremsgflush.c, src/coremsgflushsupp.c, src/coremsgflushwait.c, src/coremsginsert.c, src/coremsgseize.c, src/coremsgsubmit.c, src/coremutex.c, src/coremutexflush.c, src/coremutexseize.c, src/coremutexsurrender.c, src/coresem.c, src/coresemflush.c, src/coresemseize.c, src/coresemsurrender.c, src/coretod.c, src/coretodset.c, src/coretodtickle.c, src/coretodtoseconds.c, src/coretodvalidate.c, src/heap.c, src/heapallocate.c, src/heapextend.c, src/heapfree.c, src/heapgetinfo.c, src/heapsizeofuserarea.c, src/heapwalk.c, src/interr.c, src/isr.c, src/iterateoverthreads.c, src/mpci.c, src/object.c, src/objectallocate.c, src/objectallocatebyindex.c, src/objectclearname.c, src/objectcomparenameraw.c, src/objectcomparenamestring.c, src/objectcopynameraw.c, src/objectcopynamestring.c, src/objectextendinformation.c, src/objectfree.c, src/objectget.c, src/objectgetbyindex.c, src/objectgetisr.c, src/objectgetnext.c, src/objectgetnoprotection.c, src/objectidtoname.c, src/objectinitializeinformation.c, src/objectmp.c, src/objectnametoid.c, src/objectshrinkinformation.c, src/thread.c, src/threadchangepriority.c, src/threadclearstate.c, src/threadclose.c, src/threadcreateidle.c, src/threaddelayended.c, src/threaddispatch.c, src/threadevaluatemode.c, src/threadget.c, src/threadhandler.c, src/threadidlebody.c, src/threadinitialize.c, src/threadloadenv.c, src/threadmp.c, src/threadq.c, src/threadqdequeue.c, src/threadqdequeuefifo.c, src/threadqdequeuepriority.c, src/threadqenqueue.c, src/threadqenqueuefifo.c, src/threadqenqueuepriority.c, src/threadqextract.c, src/threadqextractfifo.c, src/threadqextractpriority.c, src/threadqextractwithproxy.c, src/threadqfirst.c, src/threadqfirstfifo.c, src/threadqfirstpriority.c, src/threadqflush.c, src/threadqtimeout.c, src/threadready.c, src/threadreset.c, src/threadresettimeslice.c, src/threadrestart.c, src/threadresume.c, src/threadrotatequeue.c, src/threadsetpriority.c, src/threadsetstate.c, src/threadsettransient.c, src/threadstackallocate.c, src/threadstackfree.c, src/threadstart.c, src/threadstartmultitasking.c, src/threadsuspend.c, src/threadtickletimeslice.c, src/threadyieldprocessor.c, src/userext.c, src/watchdog.c, src/watchdogadjust.c, src/watchdoginsert.c, src/watchdogremove.c, src/watchdogtickle.c, src/wkspace.c: URL for license changed.
  • Property mode set to 100644
File size: 6.1 KB
Line 
1/*
2 *  Multiprocessing Support for the Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/score/interr.h>
17#include <rtems/score/object.h>
18#include <rtems/score/wkspace.h>
19#include <rtems/score/thread.h>
20
21/*PAGE
22 *
23 *  _Objects_MP_Handler_initialization
24 *
25 */
26
27void _Objects_MP_Handler_initialization (
28  unsigned32 node,
29  unsigned32 maximum_nodes,
30  unsigned32 maximum_global_objects
31)
32{
33  _Objects_MP_Maximum_global_objects = maximum_global_objects;
34
35  if ( maximum_global_objects == 0 ) {
36    _Chain_Initialize_empty( &_Objects_MP_Inactive_global_objects );
37    return;
38  }
39
40  _Chain_Initialize(
41    &_Objects_MP_Inactive_global_objects,
42    _Workspace_Allocate_or_fatal_error(
43      maximum_global_objects * sizeof( Objects_MP_Control )
44    ),
45    maximum_global_objects,
46    sizeof( Objects_MP_Control )
47  );
48
49}
50
51/*PAGE
52 *
53 *  _Objects_MP_Open
54 *
55 */
56 
57void _Objects_MP_Open (
58  Objects_Information *information,
59  Objects_MP_Control  *the_global_object,
60  unsigned32           the_name,      /* XXX -- wrong for variable */
61  Objects_Id           the_id
62)
63{
64  the_global_object->Object.id = the_id;
65  the_global_object->name      = the_name;
66 
67  _Chain_Prepend(
68    &information->global_table[ _Objects_Get_node( the_id ) ],
69    &the_global_object->Object.Node
70  );
71
72}
73
74/*PAGE
75 *
76 *  _Objects_MP_Allocate_and_open
77 *
78 */
79
80boolean _Objects_MP_Allocate_and_open (
81  Objects_Information *information,
82  unsigned32           the_name,      /* XXX -- wrong for variable */
83  Objects_Id           the_id,
84  boolean              is_fatal_error
85)
86{
87  Objects_MP_Control  *the_global_object;
88
89  the_global_object = _Objects_MP_Allocate_global_object();
90  if ( _Objects_MP_Is_null_global_object( the_global_object ) ) {
91
92    if ( is_fatal_error == FALSE )
93      return FALSE;
94
95    _Internal_error_Occurred(
96      INTERNAL_ERROR_CORE,
97      TRUE,
98      INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS
99    );
100
101  }
102
103  _Objects_MP_Open( information, the_global_object, the_name, the_id );
104
105  return TRUE;
106}
107
108/*PAGE
109 *
110 *  _Objects_MP_Close
111 *
112 */
113
114void _Objects_MP_Close (
115  Objects_Information *information,
116  Objects_Id           the_id
117)
118{
119  Chain_Control      *the_chain;
120  Chain_Node         *the_node;
121  Objects_MP_Control *the_object;
122
123  the_chain = &information->global_table[ _Objects_Get_node( the_id ) ];
124
125  for ( the_node = the_chain->first ;
126        !_Chain_Is_tail( the_chain, the_node ) ;
127        the_node = the_node->next ) {
128
129    the_object = (Objects_MP_Control *) the_node;
130
131    if ( _Objects_Are_ids_equal( the_object->Object.id, the_id ) ) {
132
133      _Chain_Extract( the_node );
134      _Objects_MP_Free_global_object( the_object );
135      return;
136    }
137
138  }
139
140  _Internal_error_Occurred(
141    INTERNAL_ERROR_CORE,
142    TRUE,
143    INTERNAL_ERROR_INVALID_GLOBAL_ID
144  );
145}
146
147/*PAGE
148 *
149 *  _Objects_MP_Global_name_search
150 *
151 */
152
153Objects_Name_or_id_lookup_errors _Objects_MP_Global_name_search (
154  Objects_Information *information,
155  Objects_Name         the_name,
156  unsigned32           nodes_to_search,
157  Objects_Id          *the_id
158)
159{
160  unsigned32          low_node;
161  unsigned32          high_node;
162  unsigned32          node_index;
163  Chain_Control      *the_chain;
164  Chain_Node         *the_node;
165  Objects_MP_Control *the_object;
166  unsigned32          name_to_use;
167
168  name_to_use = *(unsigned32 *)the_name;  /* XXX only fixed length names */
169
170  if ( nodes_to_search > _Objects_Maximum_nodes )
171    return OBJECTS_INVALID_NODE;
172
173  if ( information->global_table == NULL )
174    return OBJECTS_INVALID_NAME;
175
176  if ( nodes_to_search == OBJECTS_SEARCH_ALL_NODES ||
177       nodes_to_search == OBJECTS_SEARCH_OTHER_NODES ) {
178    low_node = 1;
179    high_node = _Objects_Maximum_nodes;
180  } else {
181    low_node  =
182    high_node = nodes_to_search;
183  }
184
185  _Thread_Disable_dispatch();
186
187  for ( node_index = low_node ; node_index <= high_node ; node_index++ ) {
188
189    /*
190     *  NOTE: The local node was search (if necessary) by
191     *        _Objects_Name_to_id before this was invoked.
192     */
193
194    if ( !_Objects_Is_local_node( node_index ) ) {
195      the_chain = &information->global_table[ node_index ];
196
197      for ( the_node = the_chain->first ;
198            !_Chain_Is_tail( the_chain, the_node ) ;
199            the_node = the_node->next ) {
200
201        the_object = (Objects_MP_Control *) the_node;
202
203        if ( the_object->name == name_to_use ) {
204          *the_id = the_object->Object.id;
205          _Thread_Enable_dispatch();
206          return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
207        }
208      }
209    }
210  }
211
212  _Thread_Enable_dispatch();
213  return OBJECTS_INVALID_NAME;
214}
215
216/*PAGE
217 *
218 *  _Objects_MP_Is_remote
219 *
220 */
221
222void _Objects_MP_Is_remote (
223  Objects_Information  *information,
224  Objects_Id            the_id,
225  Objects_Locations    *location,
226  Objects_Control     **the_object
227)
228{
229  unsigned32          node;
230  Chain_Control      *the_chain;
231  Chain_Node         *the_node;
232  Objects_MP_Control *the_global_object;
233
234  node = _Objects_Get_node( the_id );
235
236  /*
237   *  NOTE: The local node was search (if necessary) by
238   *        _Objects_Name_to_id before this was invoked.
239   *
240   *        The NODE field of an object id cannot be 0
241   *        because 0 is an invalid node number.
242   */
243
244  if ( node == 0 ||
245       _Objects_Is_local_node( node ) ||
246       node > _Objects_Maximum_nodes ||
247       information->global_table == NULL ) {
248
249    *location   = OBJECTS_ERROR;
250    *the_object = NULL;
251    return;
252  }
253
254  _Thread_Disable_dispatch();
255
256  the_chain = &information->global_table[ node ];
257
258  for ( the_node = the_chain->first ;
259        !_Chain_Is_tail( the_chain, the_node ) ;
260        the_node = the_node->next ) {
261
262    the_global_object = (Objects_MP_Control *) the_node;
263
264    if ( _Objects_Are_ids_equal( the_global_object->Object.id, the_id ) ) {
265      _Thread_Unnest_dispatch();
266      *location   = OBJECTS_REMOTE;
267      *the_object = (Objects_Control *) the_global_object;
268      return;
269    }
270  }
271
272  _Thread_Enable_dispatch();
273  *location   = OBJECTS_ERROR;
274  *the_object = NULL;
275
276}
Note: See TracBrowser for help on using the repository browser.