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 | |
---|
46 | void _Objects_Shrink_information( |
---|
47 | Objects_Information *information |
---|
48 | ) |
---|
49 | { |
---|
50 | uint32_t block_count; |
---|
51 | uint32_t block; |
---|
52 | uint32_t index_base; |
---|
53 | |
---|
54 | /* |
---|
55 | * Search the list to find block or chunk with all objects inactive. |
---|
56 | */ |
---|
57 | |
---|
58 | index_base = _Objects_Get_index( information->minimum_id ); |
---|
59 | block_count = (information->maximum - index_base) / |
---|
60 | information->allocation_size; |
---|
61 | |
---|
62 | for ( block = 0; block < block_count; block++ ) { |
---|
63 | if ( information->inactive_per_block[ block ] == |
---|
64 | information->allocation_size ) { |
---|
65 | Chain_Node *node = _Chain_First( &information->Inactive ); |
---|
66 | const Chain_Node *tail = _Chain_Tail( &information->Inactive ); |
---|
67 | uint32_t index_end = index_base + information->allocation_size; |
---|
68 | |
---|
69 | while ( node != tail ) { |
---|
70 | Objects_Control *object = (Objects_Control *) node; |
---|
71 | uint32_t index = _Objects_Get_index( object->id ); |
---|
72 | |
---|
73 | /* |
---|
74 | * Get the next node before the node is extracted |
---|
75 | */ |
---|
76 | node = _Chain_Next( node ); |
---|
77 | |
---|
78 | if ( index >= index_base && index < index_end ) { |
---|
79 | _Chain_Extract( &object->Node ); |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | /* |
---|
84 | * Free the memory and reset the structures in the object' information |
---|
85 | */ |
---|
86 | |
---|
87 | _Workspace_Free( information->object_blocks[ block ] ); |
---|
88 | information->object_blocks[ block ] = NULL; |
---|
89 | information->inactive_per_block[ block ] = 0; |
---|
90 | |
---|
91 | information->inactive -= information->allocation_size; |
---|
92 | |
---|
93 | return; |
---|
94 | } |
---|
95 | |
---|
96 | index_base += information->allocation_size; |
---|
97 | } |
---|
98 | } |
---|