[rtems commit] rtems: Avoid Giant lock in rtems_object_set_name()

Sebastian Huber sebh at rtems.org
Mon May 2 10:08:07 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Apr 27 16:46:57 2016 +0200

rtems: Avoid Giant lock in rtems_object_set_name()

Update #2555.

---

 cpukit/rtems/src/rtemsobjectsetname.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/cpukit/rtems/src/rtemsobjectsetname.c b/cpukit/rtems/src/rtemsobjectsetname.c
index 5228497..ccdda15 100644
--- a/cpukit/rtems/src/rtemsobjectsetname.c
+++ b/cpukit/rtems/src/rtemsobjectsetname.c
@@ -19,8 +19,8 @@
 #endif
 
 #include <rtems/rtems/object.h>
+#include <rtems/rtems/tasks.h>
 #include <rtems/score/objectimpl.h>
-#include <rtems/score/thread.h>
 
 /*
  *  This method will set the object name based upon the user string.
@@ -33,33 +33,27 @@ rtems_status_code rtems_object_set_name(
 )
 {
   Objects_Information *information;
-  Objects_Locations    location;
   Objects_Control     *the_object;
   Objects_Id           tmpId;
 
   if ( !name )
     return RTEMS_INVALID_ADDRESS;
 
-  tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Get_executing()->Object.id : id;
+  tmpId = (id == OBJECTS_ID_OF_SELF) ? rtems_task_self() : id;
 
   information  = _Objects_Get_information_id( tmpId );
   if ( !information )
     return RTEMS_INVALID_ID;
 
-  the_object = _Objects_Get( information, tmpId, &location );
-  switch ( location ) {
+  _Objects_Allocator_lock();
+  the_object = _Objects_Get_no_protection( tmpId, information );
 
-    case OBJECTS_LOCAL:
-      _Objects_Set_name( information, the_object, name );
-      _Objects_Put( the_object );
-      return RTEMS_SUCCESSFUL;
-
-#if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:
-#endif
-    case OBJECTS_ERROR:
-      break;
+  if ( the_object == NULL ) {
+    _Objects_Allocator_unlock();
+    return RTEMS_INVALID_ID;
   }
 
-  return RTEMS_INVALID_ID;
+  _Objects_Set_name( information, the_object, name );
+  _Objects_Allocator_unlock();
+  return RTEMS_SUCCESSFUL;
 }




More information about the vc mailing list