source: rtems/cpukit/score/src/objectinitializeinformation.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: 3.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief Initialize Object Information
5 * @ingroup ScoreObject
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2011.
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#include <rtems/score/chainimpl.h>
23#include <rtems/score/interr.h>
24#include <rtems/score/sysstate.h>
25#include <rtems/score/wkspace.h>
26
27void _Objects_Do_initialize_information(
28  Objects_Information *information,
29  Objects_APIs         the_api,
30  uint16_t             the_class,
31  uint32_t             maximum,
32  uint16_t             object_size,
33  uint16_t             maximum_name_length
34#if defined(RTEMS_MULTIPROCESSING)
35  ,
36  Objects_Thread_queue_Extract_callout extract
37#endif
38)
39{
40  Objects_Maximum maximum_per_allocation;
41
42  information->the_api            = the_api;
43  information->the_class          = the_class;
44  information->object_size        = object_size;
45  information->local_table        = 0;
46  information->inactive_per_block = 0;
47  information->object_blocks      = 0;
48  information->inactive           = 0;
49  information->local_table        = NULL;
50
51  /*
52   *  Set the maximum value to 0. It will be updated when objects are
53   *  added to the inactive set from _Objects_Extend_information()
54   */
55  information->maximum = 0;
56
57  /*
58   *  Register this Object Class in the Object Information Table.
59   */
60  _Objects_Information_table[ the_api ][ the_class ] = information;
61
62  /*
63   *  Are we operating in limited or unlimited (e.g. auto-extend) mode.
64   */
65  information->auto_extend = _Objects_Is_unlimited( maximum );
66  maximum_per_allocation = _Objects_Maximum_per_allocation( maximum );
67
68  /*
69   *  Unlimited and maximum of zero is illogical.
70   */
71  if ( information->auto_extend && maximum_per_allocation == 0) {
72    _Internal_error( INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0 );
73  }
74
75  /*
76   *  The allocation unit is the maximum value
77   */
78  information->objects_per_block = maximum_per_allocation;
79
80  /*
81   *  Calculate the maximum name length
82   *
83   *  NOTE: Either 4 bytes for Classic API names or an arbitrary
84   *        number for POSIX names which are strings that may be
85   *        an odd number of bytes.
86   */
87
88  information->name_length = maximum_name_length;
89
90  _Chain_Initialize_empty( &information->Inactive );
91
92  /*
93   *  Initialize objects .. if there are any
94   */
95  if ( maximum_per_allocation ) {
96    /*
97     *  Always have the maximum size available so the current performance
98     *  figures are create are met.  If the user moves past the maximum
99     *  number then a performance hit is taken.
100     */
101    _Objects_Extend_information( information );
102  }
103
104  /*
105   *  Take care of multiprocessing
106   */
107  #if defined(RTEMS_MULTIPROCESSING)
108    information->extract = extract;
109    _RBTree_Initialize_empty( &information->Global_by_id );
110    _RBTree_Initialize_empty( &information->Global_by_name );
111  #endif
112}
Note: See TracBrowser for help on using the repository browser.