score: _Objects_Get_name_as_string()

Avoid Giant lock in _Objects_Get_name_as_string().

Update #2555.
This commit is contained in:
Sebastian Huber
2016-04-27 16:52:48 +02:00
parent f4d541ccfe
commit 77726405fa

View File

@@ -41,7 +41,7 @@ char *_Objects_Get_name_as_string(
uint32_t i; uint32_t i;
char lname[5]; char lname[5];
Objects_Control *the_object; Objects_Control *the_object;
Objects_Locations location; ISR_lock_Context lock_context;
Objects_Id tmpId; Objects_Id tmpId;
if ( length == 0 ) if ( length == 0 )
@@ -56,45 +56,35 @@ char *_Objects_Get_name_as_string(
if ( !information ) if ( !information )
return NULL; return NULL;
the_object = _Objects_Get( information, tmpId, &location ); the_object = _Objects_Get_local( tmpId, information, &lock_context );
switch ( location ) { if ( the_object == NULL ) {
return NULL;
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;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
/* not supported */
#endif
case OBJECTS_ERROR:
return NULL;
} }
return NULL; /* unreachable path */
#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';
_ISR_lock_ISR_enable( &lock_context );
return name;
} }