summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-12-10 10:04:36 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-02-12 09:08:37 +0100
commit6f3bc0e3201c903773719c369081bca06f891f1a (patch)
treea014ee0d7e247b9f2cdddd3e7b6fa50c96037345
parent32991495b48d1b5e4804b2f10a67a800f4608e75 (diff)
score: Add _Objects_Free_objects_block()
This is a preparation to allow a customization of the objects information extend. Update #3835.
-rw-r--r--cpukit/include/rtems/score/objectimpl.h11
-rw-r--r--cpukit/score/src/objectshrinkinformation.c92
2 files changed, 64 insertions, 39 deletions
diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h
index 9becb33e7d..83e93a2b12 100644
--- a/cpukit/include/rtems/score/objectimpl.h
+++ b/cpukit/include/rtems/score/objectimpl.h
@@ -95,6 +95,17 @@ void _Objects_Extend_information(
);
/**
+ * @brief Free the objects block with the specified index.
+ *
+ * @param information The objects information.
+ * @param block The block index.
+ */
+void _Objects_Free_objects_block(
+ Objects_Information *information,
+ Objects_Maximum block
+);
+
+/**
* @brief Shrinks an object class information record.
*
* This function shrinks an object class information record.
diff --git a/cpukit/score/src/objectshrinkinformation.c b/cpukit/score/src/objectshrinkinformation.c
index 9498ea2716..6f22d7bcdb 100644
--- a/cpukit/score/src/objectshrinkinformation.c
+++ b/cpukit/score/src/objectshrinkinformation.c
@@ -22,6 +22,58 @@
#include <rtems/score/chainimpl.h>
#include <rtems/score/wkspace.h>
+void _Objects_Free_objects_block(
+ Objects_Information *information,
+ Objects_Maximum block
+)
+{
+ Objects_Maximum objects_per_block;
+ Objects_Maximum index_base;
+ Objects_Maximum index_end;
+ Chain_Node *node;
+ const Chain_Node *tail;
+
+ objects_per_block = information->objects_per_block;
+
+ _Assert( _Objects_Allocator_is_owner() );
+ _Assert( _Objects_Is_auto_extend( information ) );
+ _Assert( block >= 1 );
+ _Assert(
+ block < _Objects_Get_maximum_index( information ) / objects_per_block
+ );
+
+ index_base = block * objects_per_block;
+ index_end = index_base + objects_per_block;
+ node = _Chain_First( &information->Inactive );
+ tail = _Chain_Immutable_tail( &information->Inactive );
+
+ while ( node != tail ) {
+ Objects_Control *object;
+ uint32_t index;
+
+ object = (Objects_Control *) node;
+ index = _Objects_Get_index( object->id ) - OBJECTS_INDEX_MINIMUM;
+
+ /*
+ * Get the next node before the node is extracted
+ */
+ node = _Chain_Next( node );
+
+ if ( index >= index_base && index < index_end ) {
+ _Chain_Extract_unprotected( &object->Node );
+ }
+ }
+
+ /*
+ * Free the memory and reset the structures in the object' information
+ */
+
+ _Workspace_Free( information->object_blocks[ block ] );
+ information->object_blocks[ block ] = NULL;
+ information->inactive_per_block[ block ] = 0;
+ information->inactive -= objects_per_block;
+}
+
void _Objects_Shrink_information(
Objects_Information *information
)
@@ -29,7 +81,6 @@ void _Objects_Shrink_information(
Objects_Maximum objects_per_block;
Objects_Maximum block_count;
Objects_Maximum block;
- Objects_Maximum index_base;
_Assert( _Objects_Allocator_is_owner() );
_Assert( _Objects_Is_auto_extend( information ) );
@@ -40,48 +91,11 @@ void _Objects_Shrink_information(
objects_per_block = information->objects_per_block;
block_count = _Objects_Get_maximum_index( information ) / objects_per_block;
- index_base = objects_per_block;
for ( block = 1; block < block_count; block++ ) {
if ( information->inactive_per_block[ block ] == objects_per_block ) {
- Chain_Node *node;
- const Chain_Node *tail;
- Objects_Maximum index_end;
-
- node = _Chain_First( &information->Inactive );
- tail = _Chain_Immutable_tail( &information->Inactive );
- index_end = index_base + objects_per_block;
-
- while ( node != tail ) {
- Objects_Control *object;
- uint32_t index;
-
- object = (Objects_Control *) node;
- index = _Objects_Get_index( object->id ) - OBJECTS_INDEX_MINIMUM;
-
- /*
- * Get the next node before the node is extracted
- */
- node = _Chain_Next( node );
-
- if ( index >= index_base && index < index_end ) {
- _Chain_Extract_unprotected( &object->Node );
- }
- }
-
- /*
- * Free the memory and reset the structures in the object' information
- */
-
- _Workspace_Free( information->object_blocks[ block ] );
- information->object_blocks[ block ] = NULL;
- information->inactive_per_block[ block ] = 0;
-
- information->inactive -= objects_per_block;
-
+ _Objects_Free_objects_block( information, block );
return;
}
-
- index_base += objects_per_block;
}
}