OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [src/] [objectshrinkinformation.c] - Blame information for rev 227

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  Object Handler
3
 *
4
 *
5
 *  COPYRIGHT (c) 1989-1999.
6
 *  On-Line Applications Research Corporation (OAR).
7
 *
8
 *  The license and distribution terms for this file may be
9
 *  found in the file LICENSE in this distribution or at
10
 *  http://www.OARcorp.com/rtems/license.html.
11
 *
12
 *  $Id: objectshrinkinformation.c,v 1.2 2001-09-27 11:59:34 chris Exp $
13
 */
14
 
15
#include <rtems/system.h>
16
#include <rtems/score/address.h>
17
#include <rtems/score/chain.h>
18
#include <rtems/score/object.h>
19
#if defined(RTEMS_MULTIPROCESSING)
20
#include <rtems/score/objectmp.h>
21
#endif
22
#include <rtems/score/thread.h>
23
#include <rtems/score/wkspace.h>
24
#include <rtems/score/sysstate.h>
25
#include <rtems/score/isr.h>
26
 
27
/*PAGE
28
 *
29
 *  _Objects_Shrink_information
30
 *
31
 *  This routine shrinks object information related data structures.
32
 *  The object's name and object space are released. The local_table
33
 *  etc block does not shrink. The InActive list needs to be scanned
34
 *  to find the objects are remove them.
35
 *  Input parameters:
36
 *    information     - object information table
37
 *    the_block       - the block to remove
38
 *
39
 *  Output parameters:  NONE
40
 */
41
 
42
void _Objects_Shrink_information(
43
  Objects_Information *information
44
)
45
{
46
  Objects_Control  *the_object;
47
  Objects_Control  *extract_me;
48
  unsigned32        block_count;
49
  unsigned32        block;
50
  unsigned32        index_base;
51
  unsigned32        index;
52
 
53
  /*
54
   * Search the list to find block or chunnk with all objects inactive.
55
   */
56
 
57
  index_base = _Objects_Get_index( information->minimum_id );
58
  block_count = ( information->maximum - index_base ) / information->allocation_size;
59
 
60
  for ( block = 0; block < block_count; block++ ) {
61
    if ( information->inactive_per_block[ block ] == information->allocation_size ) {
62
 
63
      /*
64
       * XXX - Not to sure how to use a chain where you need to iterate and
65
       *       and remove elements.
66
       */
67
 
68
      the_object = (Objects_Control *) information->Inactive.first;
69
 
70
      /*
71
       *  Assume the Inactive chain is never empty at this point
72
       */
73
 
74
      do {
75
        index = _Objects_Get_index( the_object->id );
76
 
77
        if ((index >= index_base) &&
78
            (index < (index_base + information->allocation_size))) {
79
 
80
          /*
81
           *  Get the next node before the node is extracted
82
           */
83
 
84
          extract_me = the_object;
85
 
86
          if ( !_Chain_Is_last( &the_object->Node ) )
87
            the_object = (Objects_Control *) the_object->Node.next;
88
          else
89
            the_object = NULL;
90
 
91
          _Chain_Extract( &extract_me->Node );
92
        }
93
        else {
94
          the_object = (Objects_Control *) the_object->Node.next;
95
        }
96
      }
97
      while ( the_object && !_Chain_Is_last( &the_object->Node ) );
98
 
99
      /*
100
       *  Free the memory and reset the structures in the object' information
101
       */
102
 
103
      _Workspace_Free( information->object_blocks[ block ] );
104
      information->name_table[ block ] = NULL;
105
      information->object_blocks[ block ] = NULL;
106
      information->inactive_per_block[ block ] = 0;
107
 
108
      information->inactive -= information->allocation_size;
109
 
110
      return;
111
    }
112
 
113
    index_base += information->allocation_size;
114
  }
115
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.