[rtems commit] score: Fix _Objects_Active_count()
Sebastian Huber
sebh at rtems.org
Thu Jul 21 07:17:29 UTC 2022
Module: rtems
Branch: 5
Commit: fc7584d71940e4bfda3efcecd1a744bcab6f40a1
Changeset: http://git.rtems.org/rtems/commit/?id=fc7584d71940e4bfda3efcecd1a744bcab6f40a1
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Jul 13 15:14:47 2022 +0200
score: Fix _Objects_Active_count()
With unlimited objects the object maximum may be larger than the sum of active
and inactive objects.
Update #4676.
---
cpukit/score/src/objectactivecount.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/cpukit/score/src/objectactivecount.c b/cpukit/score/src/objectactivecount.c
index c658fc21e3..12c15147c7 100644
--- a/cpukit/score/src/objectactivecount.c
+++ b/cpukit/score/src/objectactivecount.c
@@ -24,14 +24,22 @@ Objects_Maximum _Objects_Active_count(
const Objects_Information *information
)
{
- Objects_Maximum inactive;
- Objects_Maximum maximum;
+ Objects_Maximum active;
+ Objects_Maximum index;
+ Objects_Maximum maximum;
+ Objects_Control **local_table;
_Assert( _Objects_Allocator_is_owner() );
- inactive = (Objects_Maximum)
- _Chain_Node_count_unprotected( &information->Inactive );
+ active = 0;
maximum = _Objects_Get_maximum_index( information );
+ local_table = information->local_table;
- return maximum - inactive;
+ for ( index = 0; index < maximum; ++index ) {
+ if ( local_table[ index ] != NULL ) {
+ ++active;
+ }
+ }
+
+ return active;
}
More information about the vc
mailing list