Avoid Giant lock in _Objects_Get_name_as_string().

Update #2555.
---
 cpukit/score/src/objectgetnameasstring.c | 68 ++++++++++++++------------------
 1 file changed, 29 insertions(+), 39 deletions(-)

diff --git a/cpukit/score/src/objectgetnameasstring.c 
b/cpukit/score/src/objectgetnameasstring.c
index 7505c02..d73d8aa 100644
--- a/cpukit/score/src/objectgetnameasstring.c
+++ b/cpukit/score/src/objectgetnameasstring.c
@@ -41,7 +41,7 @@ char *_Objects_Get_name_as_string(
   uint32_t               i;
   char                   lname[5];
   Objects_Control       *the_object;
-  Objects_Locations      location;
+  ISR_lock_Context       lock_context;
   Objects_Id             tmpId;
 
   if ( length == 0 )
@@ -56,45 +56,35 @@ char *_Objects_Get_name_as_string(
   if ( !information )
     return NULL;
 
-  the_object = _Objects_Get( information, tmpId, &location );
-  switch ( location ) {
-
-    case OBJECTS_LOCAL:
-
-      #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
-        if ( information->is_string ) {
-          s = the_object->name.name_p;
-        } else
-      #endif
-      {
-        uint32_t  u32_name = (uint32_t) the_object->name.name_u32;
-
-        lname[ 0 ] = (u32_name >> 24) & 0xff;
-        lname[ 1 ] = (u32_name >> 16) & 0xff;
-        lname[ 2 ] = (u32_name >>  8) & 0xff;
-        lname[ 3 ] = (u32_name >>  0) & 0xff;
-        lname[ 4 ] = '\0';
-        s = lname;
-      }
-
-      d = name;
-      if ( s ) {
-        for ( i=0 ; i<(length-1) && *s ; i++, s++, d++ ) {
-          *d = (isprint((unsigned char)*s)) ? *s : '*';
-        }
-      }
-      *d = '\0';
-
-      _Objects_Put( the_object );
-      return name;
+  the_object = _Objects_Get_local( tmpId, information, &lock_context );
+  if ( the_object == NULL ) {
+    return NULL;
+  }
 
-#if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:
-      /* not supported */
-#endif
-    case OBJECTS_ERROR:
-      return NULL;
+  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
+    if ( information->is_string ) {
+      s = the_object->name.name_p;
+    } else
+  #endif
+  {
+    uint32_t  u32_name = (uint32_t) the_object->name.name_u32;
+
+    lname[ 0 ] = (u32_name >> 24) & 0xff;
+    lname[ 1 ] = (u32_name >> 16) & 0xff;
+    lname[ 2 ] = (u32_name >>  8) & 0xff;
+    lname[ 3 ] = (u32_name >>  0) & 0xff;
+    lname[ 4 ] = '\0';
+    s = lname;
+  }
 
+  d = name;
+  if ( s ) {
+    for ( i=0 ; i<(length-1) && *s ; i++, s++, d++ ) {
+      *d = (isprint((unsigned char)*s)) ? *s : '*';
+    }
   }
-  return NULL;                  /* unreachable path */
+  *d = '\0';
+
+  _ISR_lock_ISR_enable( &lock_context );
+  return name;
 }
-- 
1.8.4.5

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to