[rtems commit] score: Use non-inline thread queue lock ops

Sebastian Huber sebh at rtems.org
Fri Nov 4 10:08:52 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Nov  4 10:04:27 2016 +0100

score: Use non-inline thread queue lock ops

This reduces the code size and helps to reduce the amount of testing.
Hot paths can use the _Thread_queue_Queue_acquire_critical() and
_Thread_queue_Queue_release_critical() functions which are still inline.

---

 cpukit/score/include/rtems/score/threadqimpl.h | 54 ++++++++++++++--------
 cpukit/score/src/threadq.c                     | 64 ++++++++++++++++++++++++++
 2 files changed, 99 insertions(+), 19 deletions(-)

diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index f74436d..e6c8f05 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -358,20 +358,21 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release(
   _ISR_lock_ISR_enable( lock_context );
 }
 
+#if defined(RTEMS_SMP)
+void _Thread_queue_Do_acquire_critical(
+  Thread_queue_Control *the_thread_queue,
+  ISR_lock_Context     *lock_context
+);
+#else
 RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical(
   Thread_queue_Control *the_thread_queue,
   ISR_lock_Context     *lock_context
 )
 {
-  _Thread_queue_Queue_acquire_critical(
-    &the_thread_queue->Queue,
-    &the_thread_queue->Lock_stats,
-    lock_context
-  );
-#if defined(RTEMS_DEBUG) && defined(RTEMS_SMP)
-  the_thread_queue->owner = _SMP_Get_current_processor();
-#endif
+  (void) the_thread_queue;
+  (void) lock_context;
 }
+#endif
 
 RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(
   Thread_queue_Control *the_thread_queue,
@@ -384,14 +385,21 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(
   );
 }
 
+#if defined(RTEMS_SMP)
+void _Thread_queue_Acquire(
+  Thread_queue_Control *the_thread_queue,
+  Thread_queue_Context *queue_context
+);
+#else
 RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire(
   Thread_queue_Control *the_thread_queue,
   Thread_queue_Context *queue_context
 )
 {
+  (void) the_thread_queue;
   _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
-  _Thread_queue_Acquire_critical( the_thread_queue, queue_context );
 }
+#endif
 
 #if defined(RTEMS_DEBUG)
 RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_lock_owner(
@@ -406,22 +414,22 @@ RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_lock_owner(
 }
 #endif
 
+#if defined(RTEMS_SMP)
+void _Thread_queue_Do_release_critical(
+  Thread_queue_Control *the_thread_queue,
+  ISR_lock_Context     *lock_context
+);
+#else
 RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical(
   Thread_queue_Control *the_thread_queue,
   ISR_lock_Context     *lock_context
 )
 {
-#if defined(RTEMS_DEBUG)
+  (void) the_thread_queue;
+  (void) lock_context;
   _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
-#if defined(RTEMS_SMP)
-  the_thread_queue->owner = SMP_LOCK_NO_OWNER;
-#endif
-#endif
-  _Thread_queue_Queue_release_critical(
-    &the_thread_queue->Queue,
-    lock_context
-  );
 }
+#endif
 
 RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical(
   Thread_queue_Control *the_thread_queue,
@@ -434,14 +442,22 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical(
   );
 }
 
+#if defined(RTEMS_SMP)
+void _Thread_queue_Release(
+  Thread_queue_Control *the_thread_queue,
+  Thread_queue_Context *queue_context
+);
+#else
 RTEMS_INLINE_ROUTINE void _Thread_queue_Release(
   Thread_queue_Control *the_thread_queue,
   Thread_queue_Context *queue_context
 )
 {
-  _Thread_queue_Release_critical( the_thread_queue, queue_context );
+  (void) the_thread_queue;
+  _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
   _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
 }
+#endif
 
 Thread_Control *_Thread_queue_Do_dequeue(
   Thread_queue_Control          *the_thread_queue,
diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c
index ca2b900..c200079 100644
--- a/cpukit/score/src/threadq.c
+++ b/cpukit/score/src/threadq.c
@@ -64,6 +64,70 @@ RTEMS_STATIC_ASSERT(
 
 #endif /* HAVE_STRUCT__THREAD_QUEUE_QUEUE */
 
+#if defined(RTEMS_SMP)
+void _Thread_queue_Do_acquire_critical(
+  Thread_queue_Control *the_thread_queue,
+  ISR_lock_Context     *lock_context
+)
+{
+  _Thread_queue_Queue_acquire_critical(
+    &the_thread_queue->Queue,
+    &the_thread_queue->Lock_stats,
+    lock_context
+  );
+#if defined(RTEMS_DEBUG)
+  the_thread_queue->owner = _SMP_Get_current_processor();
+#endif
+}
+
+void _Thread_queue_Acquire(
+  Thread_queue_Control *the_thread_queue,
+  Thread_queue_Context *queue_context
+)
+{
+  _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
+  _Thread_queue_Queue_acquire_critical(
+    &the_thread_queue->Queue,
+    &the_thread_queue->Lock_stats,
+    &queue_context->Lock_context.Lock_context
+  );
+#if defined(RTEMS_DEBUG)
+  the_thread_queue->owner = _SMP_Get_current_processor();
+#endif
+}
+
+void _Thread_queue_Do_release_critical(
+  Thread_queue_Control *the_thread_queue,
+  ISR_lock_Context     *lock_context
+)
+{
+#if defined(RTEMS_DEBUG)
+  _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
+  the_thread_queue->owner = SMP_LOCK_NO_OWNER;
+#endif
+  _Thread_queue_Queue_release_critical(
+    &the_thread_queue->Queue,
+    lock_context
+  );
+}
+
+void _Thread_queue_Release(
+  Thread_queue_Control *the_thread_queue,
+  Thread_queue_Context *queue_context
+)
+{
+#if defined(RTEMS_DEBUG)
+  _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
+  the_thread_queue->owner = SMP_LOCK_NO_OWNER;
+#endif
+  _Thread_queue_Queue_release_critical(
+    &the_thread_queue->Queue,
+    &queue_context->Lock_context.Lock_context
+  );
+  _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
+}
+#endif
+
 void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue )
 {
   _Thread_queue_Queue_initialize( &the_thread_queue->Queue );



More information about the vc mailing list