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 | 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 chunnk with all objects inactive. |
---|
59 | */ |
---|
60 | |
---|
61 | index_base = _Objects_Get_index( information->minimum_id ); |
---|
62 | block_count = ( information->maximum - index_base ) / information->allocation_size; |
---|
63 | |
---|
64 | for ( block = 0; block < block_count; block++ ) { |
---|
65 | if ( information->inactive_per_block[ block ] == information->allocation_size ) { |
---|
66 | |
---|
67 | /* |
---|
68 | * XXX - Not to sure how to use a chain where you need to iterate and |
---|
69 | * and remove elements. |
---|
70 | */ |
---|
71 | |
---|
72 | the_object = (Objects_Control *) information->Inactive.first; |
---|
73 | |
---|
74 | /* |
---|
75 | * Assume the Inactive chain is never empty at this point |
---|
76 | */ |
---|
77 | |
---|
78 | do { |
---|
79 | index = _Objects_Get_index( the_object->id ); |
---|
80 | |
---|
81 | if ((index >= index_base) && |
---|
82 | (index < (index_base + information->allocation_size))) { |
---|
83 | |
---|
84 | /* |
---|
85 | * Get the next node before the node is extracted |
---|
86 | */ |
---|
87 | |
---|
88 | extract_me = the_object; |
---|
89 | |
---|
90 | if ( !_Chain_Is_last( &the_object->Node ) ) |
---|
91 | the_object = (Objects_Control *) the_object->Node.next; |
---|
92 | else |
---|
93 | the_object = NULL; |
---|
94 | |
---|
95 | _Chain_Extract( &extract_me->Node ); |
---|
96 | } |
---|
97 | else { |
---|
98 | the_object = (Objects_Control *) the_object->Node.next; |
---|
99 | } |
---|
100 | } |
---|
101 | while ( the_object && !_Chain_Is_last( &the_object->Node ) ); |
---|
102 | |
---|
103 | /* |
---|
104 | * Free the memory and reset the structures in the object' information |
---|
105 | */ |
---|
106 | |
---|
107 | _Workspace_Free( information->object_blocks[ block ] ); |
---|
108 | information->object_blocks[ block ] = NULL; |
---|
109 | information->inactive_per_block[ block ] = 0; |
---|
110 | |
---|
111 | information->inactive -= information->allocation_size; |
---|
112 | |
---|
113 | return; |
---|
114 | } |
---|
115 | |
---|
116 | index_base += information->allocation_size; |
---|
117 | } |
---|
118 | } |
---|