[rtems commit] score: Use allocator lock in _Objects_Get_next()

Sebastian Huber sebh at rtems.org
Wed Mar 16 06:20:13 UTC 2016


Module:    rtems
Branch:    master
Commit:    474b9beeaa5fd6153ffa8ffe10d09acdaa8609da
Changeset: http://git.rtems.org/rtems/commit/?id=474b9beeaa5fd6153ffa8ffe10d09acdaa8609da

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Mar 15 15:42:57 2016 +0100

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.

---

 cpukit/score/include/rtems/score/objectimpl.h |  5 +++-
 cpukit/score/src/objectgetnext.c              | 37 +++++----------------------
 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 933e7e9..fb2aca8 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 ec953a7..544ded7 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 924d65e..c6b8de5 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;




More information about the vc mailing list