Ignore:
Timestamp:
Nov 24, 2018, 10:51:28 AM (13 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
1c2d178
Parents:
359a3a3
git-author:
Sebastian Huber <sebastian.huber@…> (11/24/18 10:51:28)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/07/18 13:22:01)
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/score/objectimpl.h

    r359a3a3 r3899bc1a  
    121121 */
    122122typedef struct {
    123   /** This is the minimum valid id of this object class. */
    124   Objects_Id        minimum_id;
    125123  /** This is the maximum valid id of this object class. */
    126124  Objects_Id        maximum_id;
     
    191189#define _Objects_Maximum_nodes 1
    192190#endif
     191
     192/**
     193 * This is the minimum object ID index associated with an object.
     194 */
     195#define OBJECTS_INDEX_MINIMUM 1U
    193196
    194197/**
     
    833836
    834837/**
     838 * Returns the identifier with the minimum index for the specified identifier.
     839 *
     840 * The specified identifier must have valid API, class and node fields.
     841 *
     842 * @param[in] id The identifier to be processed.
     843 *
     844 * @return The corresponding ID with the minimum index.
     845 */
     846RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id( Objects_Id id )
     847{
     848  id &= ~OBJECTS_INDEX_MASK;
     849  id += (Objects_Id) OBJECTS_INDEX_MINIMUM << OBJECTS_INDEX_START_BIT;
     850  return id;
     851}
     852
     853/**
    835854 * This function sets the pointer to the local_table object
    836855 * referenced by the index.
     
    857876   *  occur in normal situations.
    858877   */
     878  _Assert( index >= OBJECTS_INDEX_MINIMUM );
    859879  _Assert( index <= information->maximum );
    860880
    861   information->local_table[ index ] = the_object;
     881  information->local_table[ index - OBJECTS_INDEX_MINIMUM ] = the_object;
    862882}
    863883
Note: See TracChangeset for help on using the changeset viewer.