source: rtems/cpukit/score/src/objectfree.c @ 1c2d178

5
Last change on this file since 1c2d178 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.3 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Free Object
5 *  @ingroup ScoreObject
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
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/assert.h>
23#include <rtems/score/chainimpl.h>
24
25void _Objects_Free(
26  Objects_Information *information,
27  Objects_Control     *the_object
28)
29{
30  _Assert( _Objects_Allocator_is_owner() );
31
32  _Chain_Append_unprotected( &information->Inactive, &the_object->Node );
33
34  if ( information->auto_extend ) {
35    Objects_Maximum objects_per_block;
36    Objects_Maximum block;
37    Objects_Maximum inactive;
38
39    objects_per_block = information->objects_per_block;
40    block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM;
41    block /= objects_per_block;
42
43    ++information->inactive_per_block[ block ];
44
45    inactive = information->inactive;
46    ++inactive;
47    information->inactive = inactive;
48
49    /*
50     *  Check if the threshold level has been met of
51     *  1.5 x objects_per_block are free.
52     */
53
54    if ( inactive > ( objects_per_block + ( objects_per_block >> 1 ) ) ) {
55      _Objects_Shrink_information( information );
56    }
57  }
58}
Note: See TracBrowser for help on using the repository browser.