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

4.115
Last change on this file since eea7c937 was a2e3f33, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 11:50:54

score: Create object implementation header

Move implementation specific parts of object.h and object.inl into new
header file objectimpl.h. The object.h contains now only the
application visible API.

  • Property mode set to 100644
File size: 2.0 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/score/objectimpl.h>
22#include <rtems/score/chainimpl.h>
23#include <rtems/score/wkspace.h>
24
25void _Objects_Shrink_information(
26  Objects_Information *information
27)
28{
29  uint32_t          block_count;
30  uint32_t          block;
31  uint32_t          index_base;
32
33  /*
34   * Search the list to find block or chunk with all objects inactive.
35   */
36
37  index_base = _Objects_Get_index( information->minimum_id );
38  block_count = (information->maximum - index_base) /
39                 information->allocation_size;
40
41  for ( block = 0; block < block_count; block++ ) {
42    if ( information->inactive_per_block[ block ] ==
43         information->allocation_size ) {
44      Chain_Node       *node = _Chain_First( &information->Inactive );
45      const Chain_Node *tail = _Chain_Immutable_tail( &information->Inactive );
46      uint32_t          index_end = index_base + information->allocation_size;
47
48      while ( node != tail ) {
49        Objects_Control *object = (Objects_Control *) node;
50        uint32_t         index = _Objects_Get_index( object->id );
51
52        /*
53         *  Get the next node before the node is extracted
54         */
55        node = _Chain_Next( node );
56
57        if ( index >= index_base && index < index_end ) {
58          _Chain_Extract( &object->Node );
59        }
60      }
61
62      /*
63       *  Free the memory and reset the structures in the object' information
64       */
65
66      _Workspace_Free( information->object_blocks[ block ] );
67      information->object_blocks[ block ] = NULL;
68      information->inactive_per_block[ block ] = 0;
69
70      information->inactive -= information->allocation_size;
71
72      return;
73    }
74
75    index_base += information->allocation_size;
76  }
77}
Note: See TracBrowser for help on using the repository browser.