summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score
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/include/rtems/score
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/include/rtems/score')
-rw-r--r--cpukit/include/rtems/score/objectimpl.h26
1 files changed, 23 insertions, 3 deletions
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. */
@@ -192,6 +190,11 @@ extern uint16_t _Objects_Maximum_nodes;
#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,
* and obtain a pointer to the appropriate object control block.
@@ -832,6 +835,22 @@ RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal(
}
/**
+ * 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;
}
/**