source: rtems/cpukit/score/src/objectnametoid.c @ 3899bc1a

5
Last change on this file since 3899bc1a was 3899bc1a, checked in by Sebastian Huber <sebastian.huber@…>, on 11/24/18 at 10:51:28

score: Optimize object lookup

Use the maximum ID for the ID to object translation. Using the maximum
ID gets rid of an additional load from the object information in
_Objects_Get(). In addition, object lookups fail for every ID in case
the object information is cleared to zero. This makes it a bit more
robust during system startup (see new tests in spconfig02).

The local table no longer needs a NULL pointer entry at array index
zero. Adjust all the object iteration loops accordingly.

Remove Objects_Information::minimum_id since it contains only redundant
information. Add _Objects_Get_minimum_id() to get the minimum ID.

Update #3621.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Object Name To Id
5 *  @ingroup Score
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2010.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/objectimpl.h>
22
23Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
24  Objects_Information *information,
25  uint32_t             name,
26  uint32_t             node,
27  Objects_Id          *id
28)
29{
30  bool                       search_local_node;
31  Objects_Control           *the_object;
32  Objects_Maximum            index;
33#if defined(RTEMS_MULTIPROCESSING)
34  Objects_Name               name_for_mp;
35#endif
36
37  /* ASSERT: information->is_string == false */
38
39  if ( !id )
40    return OBJECTS_INVALID_ADDRESS;
41
42  if ( name == 0 )
43    return OBJECTS_INVALID_NAME;
44
45  search_local_node = false;
46
47  if ( information->maximum != 0 &&
48      (node == OBJECTS_SEARCH_ALL_NODES ||
49       node == OBJECTS_SEARCH_LOCAL_NODE ||
50       _Objects_Is_local_node( node )
51      ))
52   search_local_node = true;
53
54  if ( search_local_node ) {
55    for ( index = 0; index < information->maximum; ++index ) {
56      the_object = information->local_table[ index ];
57      if ( !the_object )
58        continue;
59
60      if ( name == the_object->name.name_u32 ) {
61        *id = the_object->id;
62        return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
63      }
64    }
65  }
66
67#if defined(RTEMS_MULTIPROCESSING)
68  if ( _Objects_Is_local_node( node ) || node == OBJECTS_SEARCH_LOCAL_NODE )
69    return OBJECTS_INVALID_NAME;
70
71  name_for_mp.name_u32 = name;
72  return _Objects_MP_Global_name_search( information, name_for_mp, node, id );
73#else
74  return OBJECTS_INVALID_NAME;
75#endif
76}
Note: See TracBrowser for help on using the repository browser.