diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-15 15:42:57 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-16 07:16:58 +0100 |
commit | 474b9beeaa5fd6153ffa8ffe10d09acdaa8609da (patch) | |
tree | 6bf8a6b6d45b8b10d954c8a4a5216ad8b9bbc79c /cpukit/score/src/objectgetnext.c | |
parent | sapi: Do not disable thread dispatching (diff) | |
download | rtems-474b9beeaa5fd6153ffa8ffe10d09acdaa8609da.tar.bz2 |
score: Use allocator lock in _Objects_Get_next()
Use the object allocator lock in _Objects_Get_next() instead of disabled
thread dispatching since object creation and deletion is covered by this
lock.
Update #2555.
Diffstat (limited to 'cpukit/score/src/objectgetnext.c')
-rw-r--r-- | cpukit/score/src/objectgetnext.c | 37 |
1 files changed, 6 insertions, 31 deletions
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; } |