Changeset b9de5b3b in rtems


Ignore:
Timestamp:
07/13/22 12:42:43 (3 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5
Children:
c5b7942
Parents:
fc7584d7
git-author:
Sebastian Huber <sebastian.huber@…> (07/13/22 12:42:43)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/18/22 07:36:34)
Message:

score: Fix unlimited objects support

Commit 21275b58a5a69c3c838082ffc8a7a3641f32ea9a ("score: Static
Objects_Information initialization") introduced an off-by-one error in the
maintenance of inactive objects.

Close #4676.

Location:
cpukit
Files:
2 edited

Legend:

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

    rfc7584d7 rb9de5b3b  
    939939
    940940/**
     941 * @brief Returns true, if the object associated with the zero-based index is
     942 *   contained in an allocated block of objects, otherwise false.
     943 *
     944 * @param index is the zero-based object index.
     945 * @param objects_per_block is the object count per block.
     946 *
     947 * @retval true The object associated with the zero-based index is in an
     948 *   allocated block of objects.
     949 * @retval false Otherwise.
     950 */
     951RTEMS_INLINE_ROUTINE bool _Objects_Is_in_allocated_block(
     952  Objects_Maximum index,
     953  Objects_Maximum objects_per_block
     954)
     955{
     956  return index >= objects_per_block;
     957}
     958
     959/**
    941960 * @brief Activate the object.
    942961 *
     
    953972{
    954973  Objects_Maximum objects_per_block;
    955   Objects_Maximum block;
     974  Objects_Maximum index;
    956975
    957976  _Assert( _Objects_Is_auto_extend( information ) );
    958977
    959978  objects_per_block = information->objects_per_block;
    960   block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM;
    961 
    962   if ( block > objects_per_block ) {
    963     block /= objects_per_block;
     979  index = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM;
     980
     981  if ( _Objects_Is_in_allocated_block( index, objects_per_block ) ) {
     982    Objects_Maximum block;
     983
     984    block = index / objects_per_block;
    964985
    965986    information->inactive_per_block[ block ]--;
  • cpukit/score/src/objectfree.c

    rfc7584d7 rb9de5b3b  
    3131  if ( _Objects_Is_auto_extend( information ) ) {
    3232    Objects_Maximum objects_per_block;
    33     Objects_Maximum block;
    34     Objects_Maximum inactive;
     33    Objects_Maximum index;
    3534
    3635    objects_per_block = information->objects_per_block;
    37     block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM;
     36    index = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM;
    3837
    39     if ( block > objects_per_block ) {
    40       block /= objects_per_block;
     38    if ( _Objects_Is_in_allocated_block( index, objects_per_block ) ) {
     39      Objects_Maximum block;
     40      Objects_Maximum inactive;
     41
     42      block = index / objects_per_block;
    4143
    4244      ++information->inactive_per_block[ block ];
Note: See TracChangeset for help on using the changeset viewer.