1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Free Object |
---|
5 | * @ingroup ScoreObject |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/score/objectimpl.h> |
---|
22 | #include <rtems/score/assert.h> |
---|
23 | #include <rtems/score/chainimpl.h> |
---|
24 | |
---|
25 | void _Objects_Free( |
---|
26 | Objects_Information *information, |
---|
27 | Objects_Control *the_object |
---|
28 | ) |
---|
29 | { |
---|
30 | _Assert( _Objects_Allocator_is_owner() ); |
---|
31 | |
---|
32 | _Chain_Append_unprotected( &information->Inactive, &the_object->Node ); |
---|
33 | |
---|
34 | if ( _Objects_Is_auto_extend( information ) ) { |
---|
35 | Objects_Maximum objects_per_block; |
---|
36 | Objects_Maximum block; |
---|
37 | Objects_Maximum inactive; |
---|
38 | |
---|
39 | objects_per_block = information->objects_per_block; |
---|
40 | block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; |
---|
41 | |
---|
42 | if ( block > objects_per_block ) { |
---|
43 | block /= objects_per_block; |
---|
44 | |
---|
45 | ++information->inactive_per_block[ block ]; |
---|
46 | |
---|
47 | inactive = information->inactive; |
---|
48 | ++inactive; |
---|
49 | information->inactive = inactive; |
---|
50 | |
---|
51 | /* |
---|
52 | * Check if the threshold level has been met of |
---|
53 | * 1.5 x objects_per_block are free. |
---|
54 | */ |
---|
55 | |
---|
56 | if ( inactive > ( objects_per_block + ( objects_per_block >> 1 ) ) ) { |
---|
57 | _Objects_Shrink_information( information ); |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | } |
---|