[rtems commit] sapi: Avoid Giant lock for extensions

Sebastian Huber sebh at rtems.org
Tue Apr 19 05:22:55 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Apr  8 16:23:22 2016 +0200

sapi: Avoid Giant lock for extensions

Extension create and delete is protected by the object allocator lock.

Update #2555.

---

 cpukit/sapi/include/rtems/extensionimpl.h |  7 ++-----
 cpukit/sapi/src/extensiondelete.c         | 33 ++++++++++++-------------------
 2 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/cpukit/sapi/include/rtems/extensionimpl.h b/cpukit/sapi/include/rtems/extensionimpl.h
index e26731c..64ac600 100644
--- a/cpukit/sapi/include/rtems/extensionimpl.h
+++ b/cpukit/sapi/include/rtems/extensionimpl.h
@@ -39,13 +39,10 @@ RTEMS_INLINE_ROUTINE void _Extension_Free (
   _Objects_Free( &_Extension_Information, &the_extension->Object );
 }
 
-RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Get (
-  Objects_Id         id,
-  Objects_Locations *location
-)
+RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Get( Objects_Id id )
 {
   return (Extension_Control *)
-    _Objects_Get( &_Extension_Information, id, location );
+    _Objects_Get_no_protection( &_Extension_Information, id );
 }
 
 #ifdef __cplusplus
diff --git a/cpukit/sapi/src/extensiondelete.c b/cpukit/sapi/src/extensiondelete.c
index f851ea0..af2bd83 100644
--- a/cpukit/sapi/src/extensiondelete.c
+++ b/cpukit/sapi/src/extensiondelete.c
@@ -20,35 +20,28 @@
 #endif
 
 #include <rtems/extensionimpl.h>
-#include <rtems/score/thread.h>
 #include <rtems/score/userextimpl.h>
 
 rtems_status_code rtems_extension_delete(
   rtems_id id
 )
 {
-  Extension_Control   *the_extension;
-  Objects_Locations    location;
+  rtems_status_code  status;
+  Extension_Control *the_extension;
 
   _Objects_Allocator_lock();
-  the_extension = _Extension_Get( id, &location );
-  switch ( location ) {
-    case OBJECTS_LOCAL:
-      _User_extensions_Remove_set( &the_extension->Extension );
-      _Objects_Close( &_Extension_Information, &the_extension->Object );
-      _Objects_Put( &the_extension->Object );
-      _Extension_Free( the_extension );
-      _Objects_Allocator_unlock();
-      return RTEMS_SUCCESSFUL;
-
-#if defined(RTEMS_MULTIPROCESSING)
-    case OBJECTS_REMOTE:            /* should never return this */
-#endif
-    case OBJECTS_ERROR:
-      break;
+
+  the_extension = _Extension_Get( id );
+
+  if ( the_extension != NULL ) {
+    _Objects_Close( &_Extension_Information, &the_extension->Object );
+    _User_extensions_Remove_set( &the_extension->Extension );
+    _Extension_Free( the_extension );
+    status = RTEMS_SUCCESSFUL;
+  } else {
+    status = RTEMS_INVALID_ID;
   }
 
   _Objects_Allocator_unlock();
-
-  return RTEMS_INVALID_ID;
+  return status;
 }




More information about the vc mailing list