[rtems commit] score: _Objects_Get_isr_disable()

Sebastian Huber sebh at rtems.org
Tue Apr 21 06:26:21 UTC 2015


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Apr 20 08:52:52 2015 +0200

score: _Objects_Get_isr_disable()

Do not disable thread dispatching and do not acquire the Giant lock.
This makes it possible to use this object get variant for fine grained
locking.

Update #2273.

---

 cpukit/posix/src/mutexlocksupp.c              | 6 ++++++
 cpukit/rtems/src/semobtain.c                  | 8 ++++++++
 cpukit/score/include/rtems/score/objectimpl.h | 3 ---
 cpukit/score/src/objectgetisr.c               | 6 ------
 4 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c
index 3678a0b..92c6556 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -54,6 +54,9 @@ int _POSIX_Mutex_Lock_support(
   switch ( location ) {
 
     case OBJECTS_LOCAL:
+#if defined(RTEMS_SMP)
+      _Thread_Dispatch_disable();
+#endif
       executing = _Thread_Executing;
       _CORE_mutex_Seize(
         &the_mutex->Mutex,
@@ -63,6 +66,9 @@ int _POSIX_Mutex_Lock_support(
         timeout,
         &lock_context
       );
+#if defined(RTEMS_SMP)
+      _Thread_Enable_dispatch();
+#endif
       _Objects_Put_for_get_isr_disable( &the_mutex->Object );
       return _POSIX_Mutex_Translate_core_mutex_return_code(
         (CORE_mutex_Status) executing->Wait.return_code
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 152274e..0edac96 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -56,6 +56,7 @@ rtems_status_code rtems_semaphore_obtain(
       attribute_set = the_semaphore->attribute_set;
       wait = !_Options_Is_no_wait( option_set );
 #if defined(RTEMS_SMP)
+      _Thread_Disable_dispatch();
       if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
         MRSP_Status mrsp_status;
 
@@ -66,6 +67,7 @@ rtems_status_code rtems_semaphore_obtain(
           wait,
           timeout
         );
+        _Thread_Enable_dispatch();
         _Objects_Put_for_get_isr_disable( &the_semaphore->Object );
         return _Semaphore_Translate_MRSP_status_code( mrsp_status );
       } else
@@ -79,6 +81,9 @@ rtems_status_code rtems_semaphore_obtain(
           timeout,
           &lock_context
         );
+#if defined(RTEMS_SMP)
+        _Thread_Enable_dispatch();
+#endif
         _Objects_Put_for_get_isr_disable( &the_semaphore->Object );
         return _Semaphore_Translate_core_mutex_return_code(
                   executing->Wait.return_code );
@@ -93,6 +98,9 @@ rtems_status_code rtems_semaphore_obtain(
         timeout,
         &lock_context
       );
+#if defined(RTEMS_SMP)
+      _Thread_Enable_dispatch();
+#endif
       _Objects_Put_for_get_isr_disable( &the_semaphore->Object );
       return _Semaphore_Translate_core_semaphore_return_code(
                   executing->Wait.return_code );
diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h
index a137dea..a96dc20 100644
--- a/cpukit/score/include/rtems/score/objectimpl.h
+++ b/cpukit/score/include/rtems/score/objectimpl.h
@@ -1093,9 +1093,6 @@ RTEMS_INLINE_ROUTINE void _Objects_Put_for_get_isr_disable(
 )
 {
   (void) the_object;
-#if defined(RTEMS_SMP)
-  _Thread_Enable_dispatch();
-#endif
 }
 
 /**
diff --git a/cpukit/score/src/objectgetisr.c b/cpukit/score/src/objectgetisr.c
index 4feb7aa..b1212ac 100644
--- a/cpukit/score/src/objectgetisr.c
+++ b/cpukit/score/src/objectgetisr.c
@@ -33,18 +33,12 @@ Objects_Control *_Objects_Get_isr_disable(
   index = id - information->minimum_id + 1;
 
   if ( information->maximum >= index ) {
-#if defined(RTEMS_SMP)
-    _Thread_Disable_dispatch();
-#endif
     _ISR_lock_ISR_disable( lock_context );
     if ( (the_object = information->local_table[ index ]) != NULL ) {
       *location = OBJECTS_LOCAL;
       return the_object;
     }
     _ISR_lock_ISR_enable( lock_context );
-#if defined(RTEMS_SMP)
-    _Thread_Enable_dispatch();
-#endif
     *location = OBJECTS_ERROR;
     return NULL;
   }




More information about the vc mailing list