From 3899bc1a4b3294306ae2fd3f8ff0ee10365d9f4b Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Sat, 24 Nov 2018 11:51:28 +0100 Subject: 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. --- cpukit/include/rtems/score/objectimpl.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'cpukit/include/rtems/score') diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h index c3597c33ff..a516e21c65 100644 --- a/cpukit/include/rtems/score/objectimpl.h +++ b/cpukit/include/rtems/score/objectimpl.h @@ -120,8 +120,6 @@ typedef void ( *Objects_Thread_queue_Extract_callout )( * manage each class of objects. */ typedef struct { - /** This is the minimum valid id of this object class. */ - Objects_Id minimum_id; /** This is the maximum valid id of this object class. */ Objects_Id maximum_id; /** This points to the table of local objects. */ @@ -191,6 +189,11 @@ extern uint16_t _Objects_Maximum_nodes; #define _Objects_Maximum_nodes 1 #endif +/** + * This is the minimum object ID index associated with an object. + */ +#define OBJECTS_INDEX_MINIMUM 1U + /** * The following is the list of information blocks per API for each object * class. From the ID, we can go to one of these information blocks, @@ -831,6 +834,22 @@ RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal( return ( left == right ); } +/** + * Returns the identifier with the minimum index for the specified identifier. + * + * The specified identifier must have valid API, class and node fields. + * + * @param[in] id The identifier to be processed. + * + * @return The corresponding ID with the minimum index. + */ +RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id( Objects_Id id ) +{ + id &= ~OBJECTS_INDEX_MASK; + id += (Objects_Id) OBJECTS_INDEX_MINIMUM << OBJECTS_INDEX_START_BIT; + return id; +} + /** * This function sets the pointer to the local_table object * referenced by the index. @@ -856,9 +875,10 @@ RTEMS_INLINE_ROUTINE void _Objects_Set_local_object( * where the Id is known to be good. Therefore, this should NOT * occur in normal situations. */ + _Assert( index >= OBJECTS_INDEX_MINIMUM ); _Assert( index <= information->maximum ); - information->local_table[ index ] = the_object; + information->local_table[ index - OBJECTS_INDEX_MINIMUM ] = the_object; } /** -- cgit v1.2.3