source: rtems/cpukit/score/src/objectmp.c @ 5472ad41

4.115
Last change on this file since 5472ad41 was 64adc13, checked in by Joel Sherrill <joel.sherrill@…>, on 07/24/11 at 23:55:15

2011-07-24 Joel Sherrill <joel.sherrill@…>

  • ftpd/ftpd.c, libcsupport/src/geteuid.c, libcsupport/src/getgroups.c, libcsupport/src/getpgrp.c, libcsupport/src/getpid.c, libcsupport/src/getppid.c, libcsupport/src/setpgid.c, libcsupport/src/setsid.c, libcsupport/src/utsname.c, libmisc/stackchk/check.c, posix/include/rtems/posix/mqueue.h, posix/inline/rtems/posix/cond.inl, posix/inline/rtems/posix/mqueue.inl, posix/inline/rtems/posix/mutex.inl, posix/inline/rtems/posix/pthread.inl, posix/inline/rtems/posix/semaphore.inl, posix/inline/rtems/posix/timer.inl, posix/src/alarm.c, posix/src/barrierattrdestroy.c, posix/src/barrierattrgetpshared.c, posix/src/barrierattrinit.c, posix/src/barrierattrsetpshared.c, posix/src/cleanuppop.c, posix/src/cleanuppush.c, posix/src/clockgetcpuclockid.c, posix/src/clockgetenableattr.c, posix/src/clockgetres.c, posix/src/clockgettime.c, posix/src/clocksetenableattr.c, posix/src/clocksettime.c, posix/src/cond.c, posix/src/condattrdestroy.c, posix/src/condattrgetpshared.c, posix/src/condattrinit.c, posix/src/condattrsetpshared.c, posix/src/condbroadcast.c, posix/src/conddefaultattributes.c, posix/src/conddestroy.c, posix/src/condinit.c, posix/src/condsignal.c, posix/src/condsignalsupp.c, posix/src/condtimedwait.c, posix/src/condwait.c, posix/src/condwaitsupp.c, posix/src/keygetspecific.c, posix/src/keyrundestructors.c, posix/src/keysetspecific.c, posix/src/mprotect.c, posix/src/mqueue.c, posix/src/mqueuecreatesupp.c, posix/src/mqueuedeletesupp.c, posix/src/mqueuegetattr.c, posix/src/mqueuenotify.c, posix/src/mqueuereceive.c, posix/src/mqueuesend.c, posix/src/mqueuesendsupp.c, posix/src/mqueuesetattr.c, posix/src/mqueuetimedreceive.c, posix/src/mqueuetimedsend.c, posix/src/mqueuetranslatereturncode.c, posix/src/mqueueunlink.c, posix/src/mutex.c, posix/src/mutexattrdestroy.c, posix/src/mutexattrgetprioceiling.c, posix/src/mutexattrgetprotocol.c, posix/src/mutexattrgetpshared.c, posix/src/mutexattrinit.c, posix/src/mutexattrsetprioceiling.c, posix/src/mutexattrsetprotocol.c, posix/src/mutexattrsetpshared.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexinit.c, posix/src/mutexlock.c, posix/src/mutexlocksupp.c, posix/src/mutexsetprioceiling.c, posix/src/mutextimedlock.c, posix/src/mutextrylock.c, posix/src/mutexunlock.c, posix/src/nanosleep.c, posix/src/psignal.c, posix/src/psignalchecksignal.c, posix/src/psignalclearprocesssignals.c, posix/src/psignalclearsignals.c, posix/src/psignalsetprocesssignals.c, posix/src/psignalunblockthread.c, posix/src/pthreadinitthreads.c, posix/src/rwlockattrdestroy.c, posix/src/rwlockattrgetpshared.c, posix/src/rwlockattrinit.c, posix/src/rwlockattrsetpshared.c, posix/src/semaphore.c, posix/src/semaphoredeletesupp.c, posix/src/semaphorenametoid.c, posix/src/semaphorewaitsupp.c, posix/src/semclose.c, posix/src/semdestroy.c, posix/src/semgetvalue.c, posix/src/seminit.c, posix/src/semopen.c, posix/src/sempost.c, posix/src/semtimedwait.c, posix/src/semtrywait.c, posix/src/semunlink.c, posix/src/semwait.c, posix/src/sysconf.c, posix/src/testcancel.c, posix/src/ualarm.c, rtems/src/clockgetuptime.c, rtems/src/clockset.c, rtems/src/clocksetnsecshandler.c, rtems/src/clocktick.c, rtems/src/clocktodtoseconds.c, rtems/src/clocktodvalidate.c, rtems/src/dpmem.c, rtems/src/dpmemcreate.c, rtems/src/dpmemdelete.c, rtems/src/dpmemexternal2internal.c, rtems/src/dpmemident.c, rtems/src/dpmeminternal2external.c, rtems/src/event.c, rtems/src/eventmp.c, rtems/src/eventreceive.c, rtems/src/eventseize.c, rtems/src/eventsend.c, rtems/src/eventsurrender.c, rtems/src/eventtimeout.c, rtems/src/mp.c, rtems/src/msg.c, rtems/src/msgmp.c, rtems/src/msgqallocate.c, rtems/src/msgqbroadcast.c, rtems/src/msgqcreate.c, rtems/src/msgqdelete.c, rtems/src/msgqflush.c, rtems/src/msgqgetnumberpending.c, rtems/src/msgqident.c, rtems/src/msgqreceive.c, rtems/src/msgqtranslatereturncode.c, rtems/src/msgqurgent.c, rtems/src/part.c, rtems/src/partcreate.c, rtems/src/partdelete.c, rtems/src/partgetbuffer.c, rtems/src/partident.c, rtems/src/partmp.c, rtems/src/partreturnbuffer.c, rtems/src/ratemon.c, rtems/src/ratemoncancel.c, rtems/src/ratemoncreate.c, rtems/src/ratemondelete.c, rtems/src/ratemongetstatistics.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonident.c, rtems/src/ratemonperiod.c, rtems/src/ratemonresetstatistics.c, rtems/src/ratemontimeout.c, rtems/src/region.c, rtems/src/regioncreate.c, rtems/src/regiondelete.c, rtems/src/regionextend.c, rtems/src/regiongetfreeinfo.c, rtems/src/regiongetinfo.c, rtems/src/regiongetsegment.c, rtems/src/regiongetsegmentsize.c, rtems/src/regionident.c, rtems/src/regionmp.c, rtems/src/regionprocessqueue.c, rtems/src/regionresizesegment.c, rtems/src/regionreturnsegment.c, rtems/src/rtemsobjectgetclassicname.c, rtems/src/rtemstimer.c, rtems/src/sem.c, rtems/src/semcreate.c, rtems/src/semdelete.c, rtems/src/semflush.c, rtems/src/semident.c, rtems/src/semmp.c, rtems/src/semobtain.c, rtems/src/semrelease.c, rtems/src/semtranslatereturncode.c, rtems/src/signal.c, rtems/src/signalcatch.c, rtems/src/signalmp.c, rtems/src/signalsend.c, rtems/src/taskcreate.c, rtems/src/taskdelete.c, rtems/src/taskgetnote.c, rtems/src/taskident.c, rtems/src/taskinitusers.c, rtems/src/taskissuspended.c, rtems/src/taskmp.c, rtems/src/taskrestart.c, rtems/src/taskresume.c, rtems/src/tasks.c, rtems/src/tasksetnote.c, rtems/src/tasksetpriority.c, rtems/src/taskstart.c, rtems/src/tasksuspend.c, rtems/src/taskwakeafter.c, rtems/src/taskwakewhen.c, rtems/src/timercancel.c, rtems/src/timercreate.c, rtems/src/timerdelete.c, rtems/src/timerfireafter.c, rtems/src/timerfirewhen.c, rtems/src/timergetinfo.c, rtems/src/timerident.c, rtems/src/timerreset.c, rtems/src/timerserverfireafter.c, rtems/src/timerserverfirewhen.c, sapi/src/debug.c, sapi/src/extension.c, sapi/src/posixapi.c, sapi/src/rtemsapi.c, score/src/apiext.c, score/src/chain.c, score/src/corebarrier.c, score/src/corebarrierrelease.c, score/src/corebarrierwait.c, score/src/coremsgbroadcast.c, score/src/coremsgclose.c, score/src/coremsgflush.c, score/src/coremsgflushsupp.c, score/src/coremsgflushwait.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c, score/src/coremutex.c, score/src/coremutexflush.c, score/src/coremutexseize.c, score/src/corerwlock.c, score/src/corerwlockobtainread.c, score/src/corerwlockobtainwrite.c, score/src/corerwlockrelease.c, score/src/coresem.c, score/src/coresemflush.c, score/src/coresemsurrender.c, score/src/corespinlock.c, score/src/corespinlockrelease.c, score/src/corespinlockwait.c, score/src/coretod.c, score/src/coretodset.c, score/src/coretodtickle.c, score/src/heap.c, score/src/interr.c, score/src/mpci.c, score/src/objectallocate.c, score/src/objectextendinformation.c, score/src/objectfree.c, score/src/objectget.c, score/src/objectgetisr.c, score/src/objectgetnext.c, score/src/objectgetnoprotection.c, score/src/objectinitializeinformation.c, score/src/objectmp.c, score/src/objectnametoid.c, score/src/objectnametoidstring.c, score/src/objectshrinkinformation.c, score/src/rbtree.c, score/src/threaddelayended.c, score/src/threadhandler.c, score/src/threadinitialize.c, score/src/threadloadenv.c, score/src/threadmp.c, score/src/threadq.c, score/src/threadqdequeue.c, score/src/threadqdequeuefifo.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueue.c, score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c, score/src/threadqextract.c, score/src/threadqextractfifo.c, score/src/threadqextractpriority.c, score/src/threadqextractwithproxy.c, score/src/threadqfirst.c, score/src/threadqfirstfifo.c, score/src/threadqfirstpriority.c, score/src/threadqflush.c, score/src/threadqrequeue.c, score/src/threadstackallocate.c, score/src/threadstartmultitasking.c, score/src/watchdog.c, score/src/watchdogadjust.c, score/src/watchdoginsert.c, score/src/watchdogremove.c, score/src/watchdogtickle.c: Remove /*PAGE markers which were interpreted by a long dead print script.
  • Property mode set to 100644
File size: 6.7 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#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/config.h>
21#include <rtems/score/interr.h>
22#include <rtems/score/object.h>
23#include <rtems/score/wkspace.h>
24#include <rtems/score/thread.h>
25
26/*
27 *  _Objects_MP_Handler_early_initialization
28 *
29 */
30void _Objects_MP_Handler_early_initialization(void)
31{
32  uint32_t   node;
33  uint32_t   maximum_nodes;
34
35  node                   = _Configuration_MP_table->node;
36  maximum_nodes          = _Configuration_MP_table->maximum_nodes;
37
38  if ( node < 1 || node > maximum_nodes )
39    _Internal_error_Occurred(
40      INTERNAL_ERROR_CORE,
41      true,
42      INTERNAL_ERROR_INVALID_NODE
43    );
44
45  _Objects_Local_node    = node;
46  _Objects_Maximum_nodes = maximum_nodes;
47}
48
49/*
50 *  _Objects_MP_Handler_initialization
51 *
52 */
53
54void _Objects_MP_Handler_initialization(void)
55{
56
57  uint32_t   maximum_global_objects;
58
59  maximum_global_objects = _Configuration_MP_table->maximum_global_objects;
60
61  _Objects_MP_Maximum_global_objects = maximum_global_objects;
62
63  if ( maximum_global_objects == 0 ) {
64    _Chain_Initialize_empty( &_Objects_MP_Inactive_global_objects );
65    return;
66  }
67
68  _Chain_Initialize(
69    &_Objects_MP_Inactive_global_objects,
70    _Workspace_Allocate_or_fatal_error(
71      maximum_global_objects * sizeof( Objects_MP_Control )
72    ),
73    maximum_global_objects,
74    sizeof( Objects_MP_Control )
75  );
76
77}
78
79/*
80 *  _Objects_MP_Open
81 *
82 */
83
84void _Objects_MP_Open (
85  Objects_Information *information,
86  Objects_MP_Control  *the_global_object,
87  uint32_t             the_name,      /* XXX -- wrong for variable */
88  Objects_Id           the_id
89)
90{
91  the_global_object->Object.id = the_id;
92  the_global_object->name      = the_name;
93
94  _Chain_Prepend(
95    &information->global_table[ _Objects_Get_node( the_id ) ],
96    &the_global_object->Object.Node
97  );
98
99}
100
101/*
102 *  _Objects_MP_Allocate_and_open
103 *
104 */
105
106bool _Objects_MP_Allocate_and_open (
107  Objects_Information *information,
108  uint32_t             the_name,      /* XXX -- wrong for variable */
109  Objects_Id           the_id,
110  bool                 is_fatal_error
111)
112{
113  Objects_MP_Control  *the_global_object;
114
115  the_global_object = _Objects_MP_Allocate_global_object();
116  if ( _Objects_MP_Is_null_global_object( the_global_object ) ) {
117
118    if ( is_fatal_error == false )
119      return false;
120
121    _Internal_error_Occurred(
122      INTERNAL_ERROR_CORE,
123      true,
124      INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS
125    );
126
127  }
128
129  _Objects_MP_Open( information, the_global_object, the_name, the_id );
130
131  return true;
132}
133
134/*
135 *  _Objects_MP_Close
136 *
137 */
138
139void _Objects_MP_Close (
140  Objects_Information *information,
141  Objects_Id           the_id
142)
143{
144  Chain_Control      *the_chain;
145  Chain_Node         *the_node;
146  Objects_MP_Control *the_object;
147
148  the_chain = &information->global_table[ _Objects_Get_node( the_id ) ];
149
150  for ( the_node = _Chain_First( the_chain ) ;
151        !_Chain_Is_tail( the_chain, the_node ) ;
152        the_node = _Chain_Next( the_node ) ) {
153
154    the_object = (Objects_MP_Control *) the_node;
155
156    if ( _Objects_Are_ids_equal( the_object->Object.id, the_id ) ) {
157
158      _Chain_Extract( the_node );
159      _Objects_MP_Free_global_object( the_object );
160      return;
161    }
162
163  }
164
165  _Internal_error_Occurred(
166    INTERNAL_ERROR_CORE,
167    true,
168    INTERNAL_ERROR_INVALID_GLOBAL_ID
169  );
170}
171
172/*
173 *  _Objects_MP_Global_name_search
174 *
175 */
176
177Objects_Name_or_id_lookup_errors _Objects_MP_Global_name_search (
178  Objects_Information *information,
179  Objects_Name         the_name,
180  uint32_t             nodes_to_search,
181  Objects_Id          *the_id
182)
183{
184  uint32_t            low_node;
185  uint32_t            high_node;
186  uint32_t            node_index;
187  Chain_Control      *the_chain;
188  Chain_Node         *the_node;
189  Objects_MP_Control *the_object;
190  uint32_t            name_to_use;
191
192  name_to_use = the_name.name_u32;  /* XXX only fixed length names */
193
194  if ( nodes_to_search > _Objects_Maximum_nodes )
195    return OBJECTS_INVALID_NODE;
196
197  if ( information->global_table == NULL )
198    return OBJECTS_INVALID_NAME;
199
200  if ( nodes_to_search == OBJECTS_SEARCH_ALL_NODES ||
201       nodes_to_search == OBJECTS_SEARCH_OTHER_NODES ) {
202    low_node = 1;
203    high_node = _Objects_Maximum_nodes;
204  } else {
205    low_node  =
206    high_node = nodes_to_search;
207  }
208
209  _Thread_Disable_dispatch();
210
211  for ( node_index = low_node ; node_index <= high_node ; node_index++ ) {
212
213    /*
214     *  NOTE: The local node was search (if necessary) by
215     *        _Objects_Name_to_id_XXX before this was invoked.
216     */
217
218    if ( !_Objects_Is_local_node( node_index ) ) {
219      the_chain = &information->global_table[ node_index ];
220
221      for ( the_node = _Chain_First( the_chain ) ;
222            !_Chain_Is_tail( the_chain, the_node ) ;
223            the_node = _Chain_Next( the_node ) ) {
224
225        the_object = (Objects_MP_Control *) the_node;
226
227        if ( the_object->name == name_to_use ) {
228          *the_id = the_object->Object.id;
229          _Thread_Enable_dispatch();
230          return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
231        }
232      }
233    }
234  }
235
236  _Thread_Enable_dispatch();
237  return OBJECTS_INVALID_NAME;
238}
239
240/*
241 *  _Objects_MP_Is_remote
242 *
243 */
244
245void _Objects_MP_Is_remote (
246  Objects_Information  *information,
247  Objects_Id            the_id,
248  Objects_Locations    *location,
249  Objects_Control     **the_object
250)
251{
252  uint32_t            node;
253  Chain_Control      *the_chain;
254  Chain_Node         *the_node;
255  Objects_MP_Control *the_global_object;
256
257  node = _Objects_Get_node( the_id );
258
259  /*
260   *  NOTE: The local node was search (if necessary) by
261   *        _Objects_Name_to_id_XXX before this was invoked.
262   *
263   *        The NODE field of an object id cannot be 0
264   *        because 0 is an invalid node number.
265   */
266
267  if ( node == 0 ||
268       _Objects_Is_local_node( node ) ||
269       node > _Objects_Maximum_nodes ||
270       information->global_table == NULL ) {
271
272    *location   = OBJECTS_ERROR;
273    *the_object = NULL;
274    return;
275  }
276
277  _Thread_Disable_dispatch();
278
279  the_chain = &information->global_table[ node ];
280
281  for ( the_node = _Chain_First( the_chain ) ;
282        !_Chain_Is_tail( the_chain, the_node ) ;
283        the_node = _Chain_Next( the_node ) ) {
284
285    the_global_object = (Objects_MP_Control *) the_node;
286
287    if ( _Objects_Are_ids_equal( the_global_object->Object.id, the_id ) ) {
288      _Thread_Unnest_dispatch();
289      *location   = OBJECTS_REMOTE;
290      *the_object = (Objects_Control *) the_global_object;
291      return;
292    }
293  }
294
295  _Thread_Enable_dispatch();
296  *location   = OBJECTS_ERROR;
297  *the_object = NULL;
298
299}
300
Note: See TracBrowser for help on using the repository browser.