source: rtems/cpukit/score/src/objectshrinkinformation.c @ 21275b58

Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2018 at 6:14:51 PM

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Shrink an Object Class Information Record
5 * @ingroup ScoreCPU
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#include <rtems/score/wkspace.h>
25
26void _Objects_Shrink_information(
27  Objects_Information *information
28)
29{
30  Objects_Maximum objects_per_block;
31  Objects_Maximum block_count;
32  Objects_Maximum block;
33  Objects_Maximum index_base;
34
35  _Assert( _Objects_Allocator_is_owner() );
36  _Assert( _Objects_Is_auto_extend( information ) );
37
38  /*
39   * Search the list to find block or chunk with all objects inactive.
40   */
41
42  objects_per_block = information->objects_per_block;
43  block_count = _Objects_Get_maximum_index( information ) / objects_per_block;
44  index_base = objects_per_block;
45
46  for ( block = 1; block < block_count; block++ ) {
47    if ( information->inactive_per_block[ block ] == objects_per_block ) {
48      Chain_Node       *node;
49      const Chain_Node *tail;
50      Objects_Maximum   index_end;
51
52      node = _Chain_First( &information->Inactive );
53      tail = _Chain_Immutable_tail( &information->Inactive );
54      index_end = index_base + objects_per_block;
55
56      while ( node != tail ) {
57        Objects_Control *object;
58        uint32_t         index;
59
60        object = (Objects_Control *) node;
61        index = _Objects_Get_index( object->id ) - OBJECTS_INDEX_MINIMUM;
62
63        /*
64         *  Get the next node before the node is extracted
65         */
66        node = _Chain_Next( node );
67
68        if ( index >= index_base && index < index_end ) {
69          _Chain_Extract_unprotected( &object->Node );
70        }
71      }
72
73      /*
74       *  Free the memory and reset the structures in the object' information
75       */
76
77      _Workspace_Free( information->object_blocks[ block ] );
78      information->object_blocks[ block ] = NULL;
79      information->inactive_per_block[ block ] = 0;
80
81      information->inactive -= objects_per_block;
82
83      return;
84    }
85
86    index_base += objects_per_block;
87  }
88}
Note: See TracBrowser for help on using the repository browser.