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

4.115
Last change on this file since d7c3883 was ce002b16, checked in by Sebastian Huber <sebastian.huber@…>, on 11/25/10 at 09:27:06

2010-11-25 Sebastian Huber <sebastian.huber@…>

  • libfs/src/dosfs/fat_file.c, libfs/src/imfs/imfs_debug.c, libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs_getchild.c, posix/src/killinfo.c, score/inline/rtems/score/schedulerpriority.inl, score/inline/rtems/score/watchdog.inl, score/src/apiext.c, score/src/chain.c, score/src/coremsgflushsupp.c, score/src/coremsginsert.c, score/src/objectshrinkinformation.c, score/src/schedulerpriorityyield.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueuepriority.c, score/src/threadqextractpriority.c, score/src/threadqfirstfifo.c, score/src/threadqfirstpriority.c, score/src/threadyieldprocessor.c, score/src/userextthreadbegin.c, score/src/userextthreadcreate.c, score/src/userextthreaddelete.c, score/src/userextthreadrestart.c, score/src/userextthreadstart.c, score/src/userextthreadswitch.c, score/src/watchdogreportchain.c: Avoid chain API violations.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
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.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/address.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/object.h>
23#if defined(RTEMS_MULTIPROCESSING)
24#include <rtems/score/objectmp.h>
25#endif
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#include <rtems/score/sysstate.h>
29#include <rtems/score/isr.h>
30
31/*PAGE
32 *
33 *  _Objects_Shrink_information
34 *
35 *  This routine shrinks object information related data structures.
36 *  The object's name and object space are released. The local_table
37 *  etc block does not shrink. The InActive list needs to be scanned
38 *  to find the objects are remove them.
39 *  Input parameters:
40 *    information     - object information table
41 *    the_block       - the block to remove
42 *
43 *  Output parameters:  NONE
44 */
45
46void _Objects_Shrink_information(
47  Objects_Information *information
48)
49{
50  Objects_Control  *the_object;
51  Objects_Control  *extract_me;
52  uint32_t          block_count;
53  uint32_t          block;
54  uint32_t          index_base;
55  uint32_t          index;
56
57  /*
58   * Search the list to find block or chunk with all objects inactive.
59   */
60
61  index_base = _Objects_Get_index( information->minimum_id );
62  block_count = (information->maximum - index_base) /
63                 information->allocation_size;
64
65  for ( block = 0; block < block_count; block++ ) {
66    if ( information->inactive_per_block[ block ] ==
67         information->allocation_size ) {
68
69      /*
70       *  Assume the Inactive chain is never empty at this point
71       */
72      the_object = (Objects_Control *) _Chain_First( &information->Inactive );
73
74      do {
75         index = _Objects_Get_index( the_object->id );
76         /*
77          *  Get the next node before the node is extracted
78          */
79         extract_me = the_object;
80         the_object = (Objects_Control *) the_object->Node.next;
81         if ((index >= index_base) &&
82             (index < (index_base + information->allocation_size))) {
83           _Chain_Extract( &extract_me->Node );
84         }
85       }
86       while ( the_object );
87      /*
88       *  Free the memory and reset the structures in the object' information
89       */
90
91      _Workspace_Free( information->object_blocks[ block ] );
92      information->object_blocks[ block ] = NULL;
93      information->inactive_per_block[ block ] = 0;
94
95      information->inactive -= information->allocation_size;
96
97      return;
98    }
99
100    index_base += information->allocation_size;
101  }
102}
Note: See TracBrowser for help on using the repository browser.