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.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/score/address.h> |
---|
23 | #include <rtems/score/chain.h> |
---|
24 | #include <rtems/score/object.h> |
---|
25 | #if defined(RTEMS_MULTIPROCESSING) |
---|
26 | #include <rtems/score/objectmp.h> |
---|
27 | #endif |
---|
28 | #include <rtems/score/thread.h> |
---|
29 | #include <rtems/score/wkspace.h> |
---|
30 | #include <rtems/score/sysstate.h> |
---|
31 | #include <rtems/score/isr.h> |
---|
32 | |
---|
33 | void _Objects_Free( |
---|
34 | Objects_Information *information, |
---|
35 | Objects_Control *the_object |
---|
36 | ) |
---|
37 | { |
---|
38 | uint32_t allocation_size = information->allocation_size; |
---|
39 | |
---|
40 | _Chain_Append( &information->Inactive, &the_object->Node ); |
---|
41 | |
---|
42 | if ( information->auto_extend ) { |
---|
43 | uint32_t block; |
---|
44 | |
---|
45 | block = (uint32_t) (_Objects_Get_index( the_object->id ) - |
---|
46 | _Objects_Get_index( information->minimum_id )); |
---|
47 | block /= information->allocation_size; |
---|
48 | |
---|
49 | information->inactive_per_block[ block ]++; |
---|
50 | information->inactive++; |
---|
51 | |
---|
52 | /* |
---|
53 | * Check if the threshold level has been met of |
---|
54 | * 1.5 x allocation_size are free. |
---|
55 | */ |
---|
56 | |
---|
57 | if ( information->inactive > ( allocation_size + ( allocation_size >> 1 ) ) ) { |
---|
58 | _Objects_Shrink_information( information ); |
---|
59 | } |
---|
60 | } |
---|
61 | } |
---|