source: rtems/cpukit/score/src/objectshrinkinformation.c @ a936aa49

4.115
Last change on this file since a936aa49 was b41f2e2, checked in by Sebastian Huber <sebastian.huber@…>, on 01/03/13 at 16:07:14

score: Fix _Objects_Shrink_information()

The chain iteration was wrong. The chain tail is not an object.

  • 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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/address.h>
23#include <rtems/score/chain.h>
24#include <rtems/score/object.h>
25#if defined(RTEMS_MULTIPROCESSING)
26#include <rtems/score/objectmp.h>
27#endif
28#include <rtems/score/thread.h>
29#include <rtems/score/wkspace.h>
30#include <rtems/score/sysstate.h>
31#include <rtems/score/isr.h>
32
33void _Objects_Shrink_information(
34  Objects_Information *information
35)
36{
37  uint32_t          block_count;
38  uint32_t          block;
39  uint32_t          index_base;
40
41  /*
42   * Search the list to find block or chunk with all objects inactive.
43   */
44
45  index_base = _Objects_Get_index( information->minimum_id );
46  block_count = (information->maximum - index_base) /
47                 information->allocation_size;
48
49  for ( block = 0; block < block_count; block++ ) {
50    if ( information->inactive_per_block[ block ] ==
51         information->allocation_size ) {
52      Chain_Node       *node = _Chain_First( &information->Inactive );
53      const Chain_Node *tail = _Chain_Immutable_tail( &information->Inactive );
54      uint32_t          index_end = index_base + information->allocation_size;
55
56      while ( node != tail ) {
57        Objects_Control *object = (Objects_Control *) node;
58        uint32_t         index = _Objects_Get_index( object->id );
59
60        /*
61         *  Get the next node before the node is extracted
62         */
63        node = _Chain_Next( node );
64
65        if ( index >= index_base && index < index_end ) {
66          _Chain_Extract( &object->Node );
67        }
68      }
69
70      /*
71       *  Free the memory and reset the structures in the object' information
72       */
73
74      _Workspace_Free( information->object_blocks[ block ] );
75      information->object_blocks[ block ] = NULL;
76      information->inactive_per_block[ block ] = 0;
77
78      information->inactive -= information->allocation_size;
79
80      return;
81    }
82
83    index_base += information->allocation_size;
84  }
85}
Note: See TracBrowser for help on using the repository browser.