summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/objectextendinformation.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-11-24 11:51:28 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-12-07 14:22:01 +0100
commit3899bc1a4b3294306ae2fd3f8ff0ee10365d9f4b (patch)
tree3912fc89bbde8a64a20111e02c618e85eb7bb000 /cpukit/score/src/objectextendinformation.c
parentscore: Rename Objects_Information::allocation_size (diff)
downloadrtems-3899bc1a4b3294306ae2fd3f8ff0ee10365d9f4b.tar.bz2
score: Optimize object lookup
Use the maximum ID for the ID to object translation. Using the maximum ID gets rid of an additional load from the object information in _Objects_Get(). In addition, object lookups fail for every ID in case the object information is cleared to zero. This makes it a bit more robust during system startup (see new tests in spconfig02). The local table no longer needs a NULL pointer entry at array index zero. Adjust all the object iteration loops accordingly. Remove Objects_Information::minimum_id since it contains only redundant information. Add _Objects_Get_minimum_id() to get the minimum ID. Update #3621.
Diffstat (limited to 'cpukit/score/src/objectextendinformation.c')
-rw-r--r--cpukit/score/src/objectextendinformation.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/cpukit/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c
index b8e72f93b6..a8346ce937 100644
--- a/cpukit/score/src/objectextendinformation.c
+++ b/cpukit/score/src/objectextendinformation.c
@@ -48,7 +48,6 @@ void _Objects_Extend_information(
uint32_t block;
uint32_t index_base;
uint32_t index_end;
- uint32_t minimum_index;
uint32_t index;
uint32_t maximum;
size_t object_block_size;
@@ -65,11 +64,9 @@ void _Objects_Extend_information(
* extend the block table, then we will change do_extend.
*/
do_extend = true;
- minimum_index = _Objects_Get_index( information->minimum_id );
- index_base = minimum_index;
+ index_base = 0;
block = 0;
- /* if ( information->maximum < minimum_index ) */
if ( information->object_blocks == NULL )
block_count = 0;
else {
@@ -149,7 +146,7 @@ void _Objects_Extend_information(
* Allocate the tables and break it up.
*/
object_blocks_size = block_count * sizeof( *object_blocks );
- local_table_size = ( maximum + minimum_index ) * sizeof( *local_table );
+ local_table_size = maximum * sizeof( *local_table );
table_size = object_blocks_size
+ local_table_size
+ block_count * sizeof( *inactive_per_block );
@@ -181,7 +178,7 @@ void _Objects_Extend_information(
*/
block_count--;
- if ( information->maximum > minimum_index ) {
+ if ( information->maximum > 0 ) {
/*
* Copy each section of the table over. This has to be performed as
* separate parts as size of each block has changed.
@@ -199,15 +196,8 @@ void _Objects_Extend_information(
memcpy(
local_table,
information->local_table,
- ( information->maximum + minimum_index ) * sizeof( *local_table )
+ information->maximum * sizeof( *local_table )
);
- } else {
- /*
- * Deal with the special case of the 0 to minimum_index
- */
- for ( index = 0; index < minimum_index; index++ ) {
- local_table[ index ] = NULL;
- }
}
/*
@@ -256,7 +246,7 @@ void _Objects_Extend_information(
information->the_api,
information->the_class,
_Objects_Local_node,
- index
+ index + OBJECTS_INDEX_MINIMUM
);
_Chain_Initialize_node( &the_object->Node );