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

Last change on this file since 1c2d178 was 1c2d178, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 25, 2018 at 7:15:26 PM

score: Remove Objects_Information::maximum

This information is already present in Objects_Information::maximum_id.
Add and use _Objects_Get_maximum_index().

Update #3621.

  • Property mode set to 100644
File size: 2.2 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
37  /*
38   * Search the list to find block or chunk with all objects inactive.
39   */
40
41  objects_per_block = information->objects_per_block;
42  block_count = _Objects_Get_maximum_index( information ) / objects_per_block;
43  index_base = 0;
44
45  for ( block = 0; block < block_count; block++ ) {
46    if ( information->inactive_per_block[ block ] == objects_per_block ) {
47      Chain_Node       *node;
48      const Chain_Node *tail;
49      Objects_Maximum   index_end;
50
51      node = _Chain_First( &information->Inactive );
52      tail = _Chain_Immutable_tail( &information->Inactive );
53      index_end = index_base + objects_per_block;
54
55      while ( node != tail ) {
56        Objects_Control *object;
57        uint32_t         index;
58
59        object = (Objects_Control *) node;
60        index = _Objects_Get_index( object->id ) - OBJECTS_INDEX_MINIMUM;
61
62        /*
63         *  Get the next node before the node is extracted
64         */
65        node = _Chain_Next( node );
66
67        if ( index >= index_base && index < index_end ) {
68          _Chain_Extract_unprotected( &object->Node );
69        }
70      }
71
72      /*
73       *  Free the memory and reset the structures in the object' information
74       */
75
76      _Workspace_Free( information->object_blocks[ block ] );
77      information->object_blocks[ block ] = NULL;
78      information->inactive_per_block[ block ] = 0;
79
80      information->inactive -= objects_per_block;
81
82      return;
83    }
84
85    index_base += objects_per_block;
86  }
87}
Note: See TracBrowser for help on using the repository browser.