source: rtems/cpukit/score/src/objectfree.c @ 6b0a729b

Last change on this file since 6b0a729b was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2018 at 6:14:51 PM

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 1.4 KB
Line 
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
25void _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}
Note: See TracBrowser for help on using the repository browser.