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