diff options
-rw-r--r-- | cpukit/score/include/rtems/score/objectimpl.h | 5 | ||||
-rw-r--r-- | cpukit/score/src/objectgetnext.c | 37 | ||||
-rw-r--r-- | testsuites/sptests/spobjgetnext/init.c | 2 |
3 files changed, 10 insertions, 34 deletions
diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h index 933e7e93cf..fb2aca8408 100644 --- a/cpukit/score/include/rtems/score/objectimpl.h +++ b/cpukit/score/include/rtems/score/objectimpl.h @@ -614,7 +614,10 @@ Objects_Control *_Objects_Get_no_protection( ); /** - * Like @ref _Objects_Get, but is used to find "next" open object. + * Like @ref _Objects_Get, but is used to find "next" open + * object. + * + * Locks the object allocator mutex in case a next object exists. * * @param[in] information points to an object class information block. * @param[in] id is the Id of the object whose name we are locating. diff --git a/cpukit/score/src/objectgetnext.c b/cpukit/score/src/objectgetnext.c index ec953a7963..544ded7000 100644 --- a/cpukit/score/src/objectgetnext.c +++ b/cpukit/score/src/objectgetnext.c @@ -20,31 +20,6 @@ #include <rtems/score/objectimpl.h> -/* - * _Objects_Get_next - * - * Like _Objects_Get, but considers the 'id' as a "hint" and - * finds next valid one after that point. - * Mostly used for monitor and debug traversal of an object. - * - * Input parameters: - * information - pointer to entry in table for this class - * id - object id to search for - * location - address of where to store the location - * next_id - address to store next id to try - * - * Output parameters: - * returns - address of object if local - * location - one of the following: - * OBJECTS_ERROR - invalid object ID - * OBJECTS_REMOTE - remote object - * OBJECTS_LOCAL - local object - * next_id - will contain a reasonable "next" id to continue traversal - * - * NOTE: - * assumes can add '1' to an id to get to next index. - */ - Objects_Control * _Objects_Get_next( Objects_Information *information, @@ -70,16 +45,20 @@ _Objects_Get_next( else next_id = id; + _Objects_Allocator_lock(); + do { /* walked off end of list? */ if (_Objects_Get_index(next_id) > information->maximum) { + _Objects_Allocator_unlock(); *location_p = OBJECTS_ERROR; - goto final; + *next_id_p = OBJECTS_ID_FINAL; + return NULL; } /* try to grab one */ - object = _Objects_Get(information, next_id, location_p); + object = _Objects_Get_no_protection(information, next_id, location_p); next_id++; @@ -87,8 +66,4 @@ _Objects_Get_next( *next_id_p = next_id; return object; - -final: - *next_id_p = OBJECTS_ID_FINAL; - return 0; } diff --git a/testsuites/sptests/spobjgetnext/init.c b/testsuites/sptests/spobjgetnext/init.c index 924d65e6e8..c6b8de5a2d 100644 --- a/testsuites/sptests/spobjgetnext/init.c +++ b/testsuites/sptests/spobjgetnext/init.c @@ -54,8 +54,6 @@ int scan_objects( break; /* XXX check dispatch level with macros */ - _Thread_Enable_dispatch(); - /* XXX should be able to check that next Id is not one we have seen */ } return i; |