[PATCH 01/12] score: Add _Thread_queue_Context_set_MP_callout()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri May 27 13:50:30 UTC 2016


Add _Thread_queue_Context_set_MP_callout() to simplify
_Thread_queue_Context_initialize().  This makes it possible to more
easily add additional fields to Thread_queue_Context.
---
 cpukit/libnetworking/rtems/rtems_glue.c          |  4 +-
 cpukit/posix/include/rtems/posix/barrierimpl.h   |  2 +-
 cpukit/posix/include/rtems/posix/mqueueimpl.h    |  2 +-
 cpukit/posix/include/rtems/posix/semaphoreimpl.h |  2 +-
 cpukit/rtems/include/rtems/rtems/barrierimpl.h   |  2 +-
 cpukit/rtems/include/rtems/rtems/messageimpl.h   | 20 ++--------
 cpukit/rtems/include/rtems/rtems/semimpl.h       | 20 ++--------
 cpukit/rtems/src/msgqbroadcast.c                 | 10 ++---
 cpukit/rtems/src/msgqdelete.c                    | 10 ++---
 cpukit/rtems/src/msgqflush.c                     |  2 +-
 cpukit/rtems/src/msgqgetnumberpending.c          |  2 +-
 cpukit/rtems/src/msgqreceive.c                   |  2 +-
 cpukit/rtems/src/msgqsend.c                      | 10 ++---
 cpukit/rtems/src/msgqurgent.c                    | 10 ++---
 cpukit/rtems/src/semdelete.c                     |  6 +--
 cpukit/rtems/src/semflush.c                      | 11 +++---
 cpukit/rtems/src/semobtain.c                     |  2 +-
 cpukit/rtems/src/semrelease.c                    | 11 +++---
 cpukit/rtems/src/semsetpriority.c                |  2 +-
 cpukit/score/include/rtems/score/mrspimpl.h      |  2 +-
 cpukit/score/include/rtems/score/threadq.h       | 15 ++++++++
 cpukit/score/include/rtems/score/threadqimpl.h   | 47 +++++++++++-------------
 cpukit/score/src/apimutexlock.c                  |  2 +-
 cpukit/score/src/apimutexunlock.c                |  2 +-
 cpukit/score/src/condition.c                     |  2 +-
 cpukit/score/src/mpci.c                          |  2 +-
 cpukit/score/src/mutex.c                         |  4 +-
 cpukit/score/src/semaphore.c                     |  2 +-
 cpukit/score/src/threadqenqueue.c                | 12 +++---
 cpukit/score/src/threadrestart.c                 |  2 +-
 testsuites/sptests/spintrcritical22/init.c       |  2 +-
 testsuites/tmtests/tm26/task1.c                  |  2 +-
 32 files changed, 107 insertions(+), 119 deletions(-)

diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c
index f517c22..9b6338c 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -375,7 +375,7 @@ rtems_bsdnet_semaphore_obtain (void)
 	Status_Control status;
 	if (!the_networkSemaphore)
 		rtems_panic ("rtems-net: network sema obtain: network not initialised\n");
-	_Thread_queue_Context_initialize(&queue_context, NULL);
+	_Thread_queue_Context_initialize(&queue_context);
 	_ISR_lock_ISR_disable(&queue_context.Lock_context);
 	status = _CORE_mutex_Seize (
 		&the_networkSemaphore->Core_control.mutex,
@@ -408,7 +408,7 @@ rtems_bsdnet_semaphore_release (void)
 
 	if (!the_networkSemaphore)
 		rtems_panic ("rtems-net: network sema obtain: network not initialised\n");
-	_Thread_queue_Context_initialize(&queue_context, NULL);
+	_Thread_queue_Context_initialize(&queue_context);
 	_ISR_lock_ISR_disable(&queue_context.Lock_context);
 	status = _CORE_mutex_Surrender (
 		&the_networkSemaphore->Core_control.mutex,
diff --git a/cpukit/posix/include/rtems/posix/barrierimpl.h b/cpukit/posix/include/rtems/posix/barrierimpl.h
index 984868e..2fbc2f9 100644
--- a/cpukit/posix/include/rtems/posix/barrierimpl.h
+++ b/cpukit/posix/include/rtems/posix/barrierimpl.h
@@ -68,7 +68,7 @@ RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Get(
   Thread_queue_Context    *queue_context
 )
 {
-  _Thread_queue_Context_initialize( queue_context, NULL );
+  _Thread_queue_Context_initialize( queue_context );
   return (POSIX_Barrier_Control *) _Objects_Get(
     (Objects_Id) *barrier,
     &queue_context->Lock_context,
diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h
index 480584b..62ddbef 100644
--- a/cpukit/posix/include/rtems/posix/mqueueimpl.h
+++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h
@@ -111,7 +111,7 @@ RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get(
   Thread_queue_Context *queue_context
 )
 {
-  _Thread_queue_Context_initialize( queue_context, NULL );
+  _Thread_queue_Context_initialize( queue_context );
   return (POSIX_Message_queue_Control *) _Objects_Get(
     id,
     &queue_context->Lock_context,
diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
index 90019d7..1521ead 100644
--- a/cpukit/posix/include/rtems/posix/semaphoreimpl.h
+++ b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
@@ -59,7 +59,7 @@ RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get(
   Thread_queue_Context *queue_context
 )
 {
-  _Thread_queue_Context_initialize( queue_context, NULL );
+  _Thread_queue_Context_initialize( queue_context );
   return (POSIX_Semaphore_Control *) _Objects_Get(
     (Objects_Id) *id,
     &queue_context->Lock_context,
diff --git a/cpukit/rtems/include/rtems/rtems/barrierimpl.h b/cpukit/rtems/include/rtems/rtems/barrierimpl.h
index 6a98917..91834b8 100644
--- a/cpukit/rtems/include/rtems/rtems/barrierimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/barrierimpl.h
@@ -74,7 +74,7 @@ RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Get(
   Thread_queue_Context *queue_context
 )
 {
-  _Thread_queue_Context_initialize( queue_context, NULL );
+  _Thread_queue_Context_initialize( queue_context );
   return (Barrier_Control *)
     _Objects_Get( id, &queue_context->Lock_context, &_Barrier_Information );
 }
diff --git a/cpukit/rtems/include/rtems/rtems/messageimpl.h b/cpukit/rtems/include/rtems/rtems/messageimpl.h
index c561ff9..9c1da39 100644
--- a/cpukit/rtems/include/rtems/rtems/messageimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/messageimpl.h
@@ -87,16 +87,12 @@ RTEMS_INLINE_ROUTINE void _Message_queue_Free (
   _Objects_Free( &_Message_queue_Information, &the_message_queue->Object );
 }
 
-RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Do_get(
-  Objects_Id               id,
-  Thread_queue_Context    *queue_context
-#if defined(RTEMS_MULTIPROCESSING)
-  ,
-  Thread_queue_MP_callout  mp_callout
-#endif
+RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get(
+  Objects_Id            id,
+  Thread_queue_Context *queue_context
 )
 {
-  _Thread_queue_Context_initialize( queue_context, mp_callout );
+  _Thread_queue_Context_initialize( queue_context );
   return (Message_queue_Control *) _Objects_Get(
     id,
     &queue_context->Lock_context,
@@ -104,14 +100,6 @@ RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Do_get(
   );
 }
 
-#if defined(RTEMS_MULTIPROCESSING)
-  #define _Message_queue_Get( id, queue_context, mp_callout ) \
-    _Message_queue_Do_get( id, queue_context, mp_callout )
-#else
-  #define _Message_queue_Get( id, queue_context, mp_callout ) \
-    _Message_queue_Do_get( id, queue_context )
-#endif
-
 RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Allocate( void )
 {
   return (Message_queue_Control *)
diff --git a/cpukit/rtems/include/rtems/rtems/semimpl.h b/cpukit/rtems/include/rtems/rtems/semimpl.h
index 21e16e9..a498927 100644
--- a/cpukit/rtems/include/rtems/rtems/semimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/semimpl.h
@@ -58,16 +58,12 @@ RTEMS_INLINE_ROUTINE void _Semaphore_Free (
   _Objects_Free( &_Semaphore_Information, &the_semaphore->Object );
 }
 
-RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Do_get(
-  Objects_Id               id,
-  Thread_queue_Context    *queue_context
-#if defined(RTEMS_MULTIPROCESSING)
-  ,
-  Thread_queue_MP_callout  mp_callout
-#endif
+RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get(
+  Objects_Id            id,
+  Thread_queue_Context *queue_context
 )
 {
-  _Thread_queue_Context_initialize( queue_context, mp_callout );
+  _Thread_queue_Context_initialize( queue_context );
   return (Semaphore_Control *) _Objects_Get(
     id,
     &queue_context->Lock_context,
@@ -75,14 +71,6 @@ RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Do_get(
   );
 }
 
-#if defined(RTEMS_MULTIPROCESSING)
-  #define _Semaphore_Get( id, queue_context, mp_callout ) \
-    _Semaphore_Do_get( id, queue_context, mp_callout )
-#else
-  #define _Semaphore_Get( id, queue_context, mp_callout ) \
-    _Semaphore_Do_get( id, queue_context )
-#endif
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/cpukit/rtems/src/msgqbroadcast.c b/cpukit/rtems/src/msgqbroadcast.c
index cc38be9..4c4e04e 100644
--- a/cpukit/rtems/src/msgqbroadcast.c
+++ b/cpukit/rtems/src/msgqbroadcast.c
@@ -40,11 +40,7 @@ rtems_status_code rtems_message_queue_broadcast(
     return RTEMS_INVALID_ADDRESS;
   }
 
-  the_message_queue = _Message_queue_Get(
-    id,
-    &queue_context,
-    _Message_queue_Core_message_queue_mp_support
-  );
+  the_message_queue = _Message_queue_Get( id, &queue_context );
 
   if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
@@ -54,6 +50,10 @@ rtems_status_code rtems_message_queue_broadcast(
 #endif
   }
 
+  _Thread_queue_Context_set_MP_callout(
+    &queue_context,
+    _Message_queue_Core_message_queue_mp_support
+  );
   status = _CORE_message_queue_Broadcast(
     &the_message_queue->message_queue,
     buffer,
diff --git a/cpukit/rtems/src/msgqdelete.c b/cpukit/rtems/src/msgqdelete.c
index 94175e6..7a3e40a 100644
--- a/cpukit/rtems/src/msgqdelete.c
+++ b/cpukit/rtems/src/msgqdelete.c
@@ -29,11 +29,7 @@ rtems_status_code rtems_message_queue_delete(
   Thread_queue_Context   queue_context;
 
   _Objects_Allocator_lock();
-  the_message_queue = _Message_queue_Get(
-    id,
-    &queue_context,
-    _Message_queue_MP_Send_object_was_deleted
-  );
+  the_message_queue = _Message_queue_Get( id, &queue_context );
 
   if ( the_message_queue == NULL ) {
     _Objects_Allocator_unlock();
@@ -54,6 +50,10 @@ rtems_status_code rtems_message_queue_delete(
 
   _Objects_Close( &_Message_queue_Information, &the_message_queue->Object );
 
+  _Thread_queue_Context_set_MP_callout(
+    &queue_context,
+    _Message_queue_MP_Send_object_was_deleted
+  );
   _CORE_message_queue_Close(
     &the_message_queue->message_queue,
     &queue_context
diff --git a/cpukit/rtems/src/msgqflush.c b/cpukit/rtems/src/msgqflush.c
index b4419d1..16f7432 100644
--- a/cpukit/rtems/src/msgqflush.c
+++ b/cpukit/rtems/src/msgqflush.c
@@ -32,7 +32,7 @@ rtems_status_code rtems_message_queue_flush(
     return RTEMS_INVALID_ADDRESS;
   }
 
-  the_message_queue = _Message_queue_Get( id, &queue_context, NULL );
+  the_message_queue = _Message_queue_Get( id, &queue_context );
 
   if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/msgqgetnumberpending.c b/cpukit/rtems/src/msgqgetnumberpending.c
index d2f7820..2a49711 100644
--- a/cpukit/rtems/src/msgqgetnumberpending.c
+++ b/cpukit/rtems/src/msgqgetnumberpending.c
@@ -32,7 +32,7 @@ rtems_status_code rtems_message_queue_get_number_pending(
     return RTEMS_INVALID_ADDRESS;
   }
 
-  the_message_queue = _Message_queue_Get( id, &queue_context, NULL );
+  the_message_queue = _Message_queue_Get( id, &queue_context );
 
   if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c
index 66e38f7..75c15be 100644
--- a/cpukit/rtems/src/msgqreceive.c
+++ b/cpukit/rtems/src/msgqreceive.c
@@ -45,7 +45,7 @@ rtems_status_code rtems_message_queue_receive(
     return RTEMS_INVALID_ADDRESS;
   }
 
-  the_message_queue = _Message_queue_Get( id, &queue_context, NULL );
+  the_message_queue = _Message_queue_Get( id, &queue_context );
 
   if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/msgqsend.c b/cpukit/rtems/src/msgqsend.c
index 9489081..7968281 100644
--- a/cpukit/rtems/src/msgqsend.c
+++ b/cpukit/rtems/src/msgqsend.c
@@ -35,11 +35,7 @@ rtems_status_code rtems_message_queue_send(
     return RTEMS_INVALID_ADDRESS;
   }
 
-  the_message_queue = _Message_queue_Get(
-    id,
-    &queue_context,
-    _Message_queue_Core_message_queue_mp_support
-  );
+  the_message_queue = _Message_queue_Get( id, &queue_context );
 
   if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
@@ -53,6 +49,10 @@ rtems_status_code rtems_message_queue_send(
     &the_message_queue->message_queue,
     &queue_context
   );
+  _Thread_queue_Context_set_MP_callout(
+    &queue_context,
+    _Message_queue_Core_message_queue_mp_support
+  );
   status = _CORE_message_queue_Send(
     &the_message_queue->message_queue,
     buffer,
diff --git a/cpukit/rtems/src/msgqurgent.c b/cpukit/rtems/src/msgqurgent.c
index 6522d8f..6c6379d 100644
--- a/cpukit/rtems/src/msgqurgent.c
+++ b/cpukit/rtems/src/msgqurgent.c
@@ -35,11 +35,7 @@ rtems_status_code rtems_message_queue_urgent(
     return RTEMS_INVALID_ADDRESS;
   }
 
-  the_message_queue = _Message_queue_Get(
-    id,
-    &queue_context,
-    _Message_queue_Core_message_queue_mp_support
-  );
+  the_message_queue = _Message_queue_Get( id, &queue_context );
 
   if ( the_message_queue == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
@@ -53,6 +49,10 @@ rtems_status_code rtems_message_queue_urgent(
     &the_message_queue->message_queue,
     &queue_context
   );
+  _Thread_queue_Context_set_MP_callout(
+    &queue_context,
+    _Message_queue_Core_message_queue_mp_support
+  );
   status = _CORE_message_queue_Urgent(
     &the_message_queue->message_queue,
     buffer,
diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c
index 405c805..13f2bf0 100644
--- a/cpukit/rtems/src/semdelete.c
+++ b/cpukit/rtems/src/semdelete.c
@@ -31,11 +31,7 @@ rtems_status_code rtems_semaphore_delete(
   rtems_attribute       attribute_set;
 
   _Objects_Allocator_lock();
-  the_semaphore = _Semaphore_Get(
-    id,
-    &queue_context,
-    _Semaphore_MP_Send_object_was_deleted
-  );
+  the_semaphore = _Semaphore_Get( id, &queue_context );
 
   if ( the_semaphore == NULL ) {
     _Objects_Allocator_unlock();
diff --git a/cpukit/rtems/src/semflush.c b/cpukit/rtems/src/semflush.c
index 7330535..07d4aa9 100644
--- a/cpukit/rtems/src/semflush.c
+++ b/cpukit/rtems/src/semflush.c
@@ -27,11 +27,7 @@ rtems_status_code rtems_semaphore_flush( rtems_id id )
   Thread_queue_Context  queue_context;
   rtems_attribute       attribute_set;
 
-  the_semaphore = _Semaphore_Get(
-    id,
-    &queue_context,
-    _Semaphore_MP_Send_object_was_deleted
-  );
+  the_semaphore = _Semaphore_Get( id, &queue_context );
 
   if ( the_semaphore == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
@@ -45,6 +41,11 @@ rtems_status_code rtems_semaphore_flush( rtems_id id )
 
   attribute_set = the_semaphore->attribute_set;
 
+  _Thread_queue_Context_set_MP_callout(
+    &queue_context,
+    _Semaphore_MP_Send_object_was_deleted
+  );
+
 #if defined(RTEMS_SMP)
   if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
     _ISR_lock_ISR_enable( &queue_context.Lock_context );
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 527f7ea..06c2e10 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -46,7 +46,7 @@ rtems_status_code rtems_semaphore_obtain(
   bool                  wait;
   Status_Control        status;
 
-  the_semaphore = _Semaphore_Get( id, &queue_context, NULL );
+  the_semaphore = _Semaphore_Get( id, &queue_context );
 
   if ( the_semaphore == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/semrelease.c b/cpukit/rtems/src/semrelease.c
index 007914c..10fe743 100644
--- a/cpukit/rtems/src/semrelease.c
+++ b/cpukit/rtems/src/semrelease.c
@@ -32,11 +32,7 @@ rtems_status_code rtems_semaphore_release( rtems_id id )
   rtems_attribute       attribute_set;
   Status_Control        status;
 
-  the_semaphore = _Semaphore_Get(
-    id,
-    &queue_context,
-    _Semaphore_Core_mutex_mp_support
-  );
+  the_semaphore = _Semaphore_Get( id, &queue_context );
 
   if ( the_semaphore == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
@@ -46,6 +42,11 @@ rtems_status_code rtems_semaphore_release( rtems_id id )
 #endif
   }
 
+  _Thread_queue_Context_set_MP_callout(
+    &queue_context,
+    _Semaphore_Core_mutex_mp_support
+  );
+
   attribute_set = the_semaphore->attribute_set;
 #if defined(RTEMS_SMP)
   if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
diff --git a/cpukit/rtems/src/semsetpriority.c b/cpukit/rtems/src/semsetpriority.c
index 4deee3d..ee6614a 100644
--- a/cpukit/rtems/src/semsetpriority.c
+++ b/cpukit/rtems/src/semsetpriority.c
@@ -103,7 +103,7 @@ rtems_status_code rtems_semaphore_set_priority(
     return RTEMS_INVALID_ID;
   }
 
-  the_semaphore = _Semaphore_Get( semaphore_id, &queue_context, NULL );
+  the_semaphore = _Semaphore_Get( semaphore_id, &queue_context );
 
   if ( the_semaphore == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index ffdc802..5a1fcda 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -189,7 +189,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Timeout( Watchdog_Control *watchdog )
   Thread_Control *thread = rival->thread;
   Thread_queue_Context queue_context;
 
-  _Thread_queue_Context_initialize( &queue_context, NULL );
+  _Thread_queue_Context_initialize( &queue_context );
   _ISR_lock_ISR_disable( &queue_context.Lock_context );
   _MRSP_Acquire_critical( mrsp, &queue_context );
 
diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h
index 27af89f..2859c79 100644
--- a/cpukit/score/include/rtems/score/threadq.h
+++ b/cpukit/score/include/rtems/score/threadq.h
@@ -63,7 +63,22 @@ typedef void ( *Thread_queue_MP_callout )(
  * @see _Thread_queue_Context_initialize().
  */
 typedef struct {
+  /**
+   * @brief The lock context for the thread queue acquire and release
+   * operations.
+   */
   ISR_lock_Context Lock_context;
+
+  /**
+   * @brief Callout to unblock the thread in case it is actually a thread
+   * proxy.
+   *
+   * This field is only used on multiprocessing configurations.  Used by
+   * thread queue extract and unblock methods for objects with multiprocessing
+   * (MP) support.
+   *
+   * @see _Thread_queue_Context_set_MP_callout().
+   */
 #if defined(RTEMS_MULTIPROCESSING)
   Thread_queue_MP_callout mp_callout;
 #endif
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index 7489d54..7772959 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -53,47 +53,44 @@ typedef struct {
 #endif
 } Thread_queue_Syslock_queue;
 
-RTEMS_INLINE_ROUTINE void _Thread_queue_Do_context_initialize(
-  Thread_queue_Context    *queue_context
-#if defined(RTEMS_MULTIPROCESSING)
-  ,
-  Thread_queue_MP_callout  mp_callout
-#endif
+/**
+ * @brief Initializes a thread queue context.
+ *
+ * @param queue_context The thread queue context to initialize.
+ */
+RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(
+  Thread_queue_Context *queue_context
 )
 {
-#if defined(RTEMS_MULTIPROCESSING)
-  queue_context->mp_callout = mp_callout;
+#if defined(RTEMS_MULTIPROCESSING) && defined(RTEMS_DEBUG)
+  queue_context->mp_callout = NULL;
 #else
   (void) queue_context;
 #endif
 }
 
 /**
- * @brief Initializes a thread queue context.
+ * @brief Sets the MP callout in the thread queue context.
  *
- * @param queue_context The thread queue context to initialize.
+ * @param queue_context The thread queue context.
  * @param mp_callout Callout to unblock the thread in case it is actually a
  *   thread proxy.  This parameter is only used on multiprocessing
  *   configurations.  Used by thread queue extract and unblock methods for
  *   objects with multiprocessing (MP) support.
  */
 #if defined(RTEMS_MULTIPROCESSING)
-  #define _Thread_queue_Context_initialize( \
-    queue_context, \
-    mp_callout \
-  ) \
-    _Thread_queue_Do_context_initialize( \
-      queue_context, \
-      mp_callout \
-    )
+RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_MP_callout(
+  Thread_queue_Context    *queue_context,
+  Thread_queue_MP_callout  mp_callout
+)
+{
+  queue_context->mp_callout = mp_callout;
+}
 #else
-  #define _Thread_queue_Context_initialize( \
-    queue_context, \
-    mp_callout \
-  ) \
-    _Thread_queue_Do_context_initialize( \
-      queue_context \
-    )
+#define _Thread_queue_Context_set_MP_callout( queue_context, mp_callout ) \
+  do { \
+    (void) queue_context; \
+  } while ( 0 )
 #endif
 
 RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize(
diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c
index 11d12c5..7a7f911 100644
--- a/cpukit/score/src/apimutexlock.c
+++ b/cpukit/score/src/apimutexlock.c
@@ -31,7 +31,7 @@ void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
   previous_thread_life_state =
     _Thread_Set_life_protection( THREAD_LIFE_PROTECTED );
 
-  _Thread_queue_Context_initialize( &queue_context, NULL );
+  _Thread_queue_Context_initialize( &queue_context );
   _ISR_lock_ISR_disable( &queue_context.Lock_context );
 
   _CORE_mutex_Seize(
diff --git a/cpukit/score/src/apimutexunlock.c b/cpukit/score/src/apimutexunlock.c
index f0f114e..486301f 100644
--- a/cpukit/score/src/apimutexunlock.c
+++ b/cpukit/score/src/apimutexunlock.c
@@ -31,7 +31,7 @@ void _API_Mutex_Unlock( API_Mutex_Control *the_mutex )
   previous_thread_life_state = the_mutex->previous_thread_life_state;
   restore_thread_life_protection = the_mutex->Mutex.nest_count == 1;
 
-  _Thread_queue_Context_initialize( &queue_context, NULL );
+  _Thread_queue_Context_initialize( &queue_context );
   _ISR_lock_ISR_disable( &queue_context.Lock_context );
   _CORE_mutex_Surrender( &the_mutex->Mutex, &queue_context );
 
diff --git a/cpukit/score/src/condition.c b/cpukit/score/src/condition.c
index 39924e8..fae150a 100644
--- a/cpukit/score/src/condition.c
+++ b/cpukit/score/src/condition.c
@@ -247,7 +247,7 @@ static void _Condition_Wake( struct _Condition_Control *_condition, int count )
   Condition_Context  context;
 
   condition = _Condition_Get( _condition );
-  _Thread_queue_Context_initialize( &context.Base, NULL );
+  _Thread_queue_Context_initialize( &context.Base );
   _ISR_lock_ISR_disable( &context.Base.Lock_context );
   _Condition_Queue_acquire_critical( condition, &context.Base.Lock_context );
 
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index 78d8e65..1e26b1f 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -325,7 +325,7 @@ void _MPCI_Receive_server(
   Thread_queue_Context   queue_context;
 
   executing = _Thread_Get_executing();
-  _Thread_queue_Context_initialize( &queue_context, NULL );
+  _Thread_queue_Context_initialize( &queue_context );
 
   for ( ; ; ) {
 
diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c
index 28936d6..e93a8e4 100644
--- a/cpukit/score/src/mutex.c
+++ b/cpukit/score/src/mutex.c
@@ -300,7 +300,7 @@ void _Mutex_Release( struct _Mutex_Control *_mutex )
   Thread_Control       *executing;
 
   mutex = _Mutex_Get( _mutex );
-  _Thread_queue_Context_initialize( &queue_context, NULL );
+  _Thread_queue_Context_initialize( &queue_context );
   executing = _Mutex_Queue_acquire( mutex, &queue_context.Lock_context );
 
   _Assert( mutex->owner == executing );
@@ -429,7 +429,7 @@ void _Mutex_recursive_Release( struct _Mutex_recursive_Control *_mutex )
   unsigned int             nest_level;
 
   mutex = _Mutex_recursive_Get( _mutex );
-  _Thread_queue_Context_initialize( &queue_context, NULL );
+  _Thread_queue_Context_initialize( &queue_context );
   executing = _Mutex_Queue_acquire(
     &mutex->Mutex,
     &queue_context.Lock_context
diff --git a/cpukit/score/src/semaphore.c b/cpukit/score/src/semaphore.c
index ea0835d..72abd9e 100644
--- a/cpukit/score/src/semaphore.c
+++ b/cpukit/score/src/semaphore.c
@@ -114,7 +114,7 @@ void _Semaphore_Post( struct _Semaphore_Control *_sem )
   Thread_queue_Heads   *heads;
 
   sem = _Semaphore_Get( _sem );
-  _Thread_queue_Context_initialize( &queue_context, NULL );
+  _Thread_queue_Context_initialize( &queue_context );
   _Semaphore_Queue_acquire( sem, &queue_context.Lock_context );
 
   heads = sem->Queue.Queue.heads;
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 948275b..4eaafa9 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -195,10 +195,7 @@ void _Thread_queue_Extract( Thread_Control *the_thread )
   void                 *lock;
   Thread_queue_Queue   *queue;
 
-  _Thread_queue_Context_initialize(
-    &queue_context,
-    _Thread_queue_MP_callout_do_nothing
-  );
+  _Thread_queue_Context_initialize( &queue_context );
   lock = _Thread_Lock_acquire( the_thread, &queue_context.Lock_context );
 
   queue = the_thread->Wait.queue;
@@ -206,6 +203,10 @@ void _Thread_queue_Extract( Thread_Control *the_thread )
   if ( queue != NULL ) {
     _SMP_Assert( lock == &queue->Lock );
 
+    _Thread_queue_Context_set_MP_callout(
+      &queue_context,
+      _Thread_queue_MP_callout_do_nothing
+    );
     _Thread_queue_Extract_critical(
       queue,
       the_thread->Wait.operations,
@@ -229,7 +230,8 @@ Thread_Control *_Thread_queue_Do_dequeue(
   Thread_queue_Context  queue_context;
   Thread_Control       *the_thread;
 
-  _Thread_queue_Context_initialize( &queue_context, mp_callout );
+  _Thread_queue_Context_initialize( &queue_context );
+  _Thread_queue_Context_set_MP_callout( &queue_context, mp_callout );
   _Thread_queue_Acquire( the_thread_queue, &queue_context.Lock_context );
 
   the_thread = _Thread_queue_First_locked( the_thread_queue, operations );
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index f9636e6..3bddac4 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -118,7 +118,7 @@ static void _Thread_Wake_up_joining_threads( Thread_Control *the_thread )
   join_context.exit_value = the_thread->Life.exit_value;
 #endif
 
-  _Thread_queue_Context_initialize( &join_context.Base, NULL );
+  _Thread_queue_Context_initialize( &join_context.Base );
   _Thread_queue_Acquire(
     &the_thread->Join_queue,
     &join_context.Base.Lock_context
diff --git a/testsuites/sptests/spintrcritical22/init.c b/testsuites/sptests/spintrcritical22/init.c
index 3670d1a..9b5c5e1 100644
--- a/testsuites/sptests/spintrcritical22/init.c
+++ b/testsuites/sptests/spintrcritical22/init.c
@@ -36,7 +36,7 @@ static Semaphore_Control *get_semaphore_control(rtems_id id)
   Thread_queue_Context queue_context;
   Semaphore_Control *sem;
 
-  sem = _Semaphore_Get(id, &queue_context, NULL);
+  sem = _Semaphore_Get(id, &queue_context);
   rtems_test_assert(sem != NULL);
   _ISR_lock_ISR_enable(&queue_context.Lock_context);
 
diff --git a/testsuites/tmtests/tm26/task1.c b/testsuites/tmtests/tm26/task1.c
index 68cb246..38fb0ea 100644
--- a/testsuites/tmtests/tm26/task1.c
+++ b/testsuites/tmtests/tm26/task1.c
@@ -514,7 +514,7 @@ void complete_test( void )
 
   benchmark_timer_initialize();
     for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
-      (void) _Semaphore_Get( Semaphore_id, &queue_context, NULL );
+      (void) _Semaphore_Get( Semaphore_id, &queue_context );
       _ISR_lock_ISR_enable( &queue_context.Lock_context );
     }
   semaphore_get_time = benchmark_timer_read();
-- 
1.8.4.5



More information about the devel mailing list