[PATCH 2/8] score: Introduce Thread_queue_Lock_context

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Sep 6 12:40:22 UTC 2016


Introduce Thread_queue_Lock_context to contain the context necessary for
thread queue lock and thread wait lock acquire/release operations to
reduce the Thread_Control size.
---
 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/posixapi.h      |  14 ++-
 cpukit/posix/include/rtems/posix/semaphoreimpl.h |   2 +-
 cpukit/posix/src/condwaitsupp.c                  |   4 +-
 cpukit/posix/src/mqueuerecvsupp.c                |   4 +-
 cpukit/posix/src/mqueuesendsupp.c                |   2 +-
 cpukit/posix/src/pthreadgetschedparam.c          |   2 +-
 cpukit/posix/src/pthreadjoin.c                   |  18 ++--
 cpukit/posix/src/semunlink.c                     |   2 +-
 cpukit/rtems/include/rtems/rtems/barrierimpl.h   |   7 +-
 cpukit/rtems/include/rtems/rtems/messageimpl.h   |   2 +-
 cpukit/rtems/include/rtems/rtems/semimpl.h       |   2 +-
 cpukit/rtems/src/semcreate.c                     |   2 +-
 cpukit/rtems/src/tasksetscheduler.c              |   6 +-
 cpukit/score/include/rtems/score/coremuteximpl.h |   6 +-
 cpukit/score/include/rtems/score/mrspimpl.h      |  20 ++--
 cpukit/score/include/rtems/score/threadimpl.h    |  80 +++++++++-------
 cpukit/score/include/rtems/score/threadq.h       | 112 ++++++++++++-----------
 cpukit/score/include/rtems/score/threadqimpl.h   |  12 +--
 cpukit/score/src/apimutexlock.c                  |   2 +-
 cpukit/score/src/apimutexunlock.c                |   2 +-
 cpukit/score/src/condition.c                     |  26 +++---
 cpukit/score/src/coremsgbroadcast.c              |   2 +-
 cpukit/score/src/coremutexseize.c                |   2 +-
 cpukit/score/src/futex.c                         |   6 +-
 cpukit/score/src/mpci.c                          |   4 +-
 cpukit/score/src/mutex.c                         |   6 +-
 cpukit/score/src/semaphore.c                     |   6 +-
 cpukit/score/src/threadqenqueue.c                |  52 ++++++-----
 cpukit/score/src/threadqflush.c                  |   6 +-
 cpukit/score/src/threadrestart.c                 |   2 +-
 testsuites/sptests/spintrcritical22/init.c       |   2 +-
 testsuites/tmtests/tm26/task1.c                  |   2 +-
 35 files changed, 237 insertions(+), 188 deletions(-)

diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c
index 2fca0e0..9a7f82f 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -375,7 +375,7 @@ rtems_bsdnet_semaphore_obtain (void)
 	if (!the_networkSemaphore)
 		rtems_panic ("rtems-net: network sema obtain: network not initialised\n");
 	_Thread_queue_Context_initialize(&queue_context);
-	_ISR_lock_ISR_disable(&queue_context.Lock_context);
+	_ISR_lock_ISR_disable(&queue_context.Lock_context.Lock_context);
 	_Thread_queue_Context_set_no_timeout( &queue_context );
 	status = _CORE_recursive_mutex_Seize (
 		&the_networkSemaphore->Core_control.Mutex.Recursive,
@@ -409,7 +409,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);
-	_ISR_lock_ISR_disable(&queue_context.Lock_context);
+	_ISR_lock_ISR_disable(&queue_context.Lock_context.Lock_context);
 	status = _CORE_recursive_mutex_Surrender(
 		&the_networkSemaphore->Core_control.Mutex.Recursive,
 		_Thread_Executing,
diff --git a/cpukit/posix/include/rtems/posix/barrierimpl.h b/cpukit/posix/include/rtems/posix/barrierimpl.h
index 2fbc2f9..fae66a6 100644
--- a/cpukit/posix/include/rtems/posix/barrierimpl.h
+++ b/cpukit/posix/include/rtems/posix/barrierimpl.h
@@ -71,7 +71,7 @@ RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Get(
   _Thread_queue_Context_initialize( queue_context );
   return (POSIX_Barrier_Control *) _Objects_Get(
     (Objects_Id) *barrier,
-    &queue_context->Lock_context,
+    &queue_context->Lock_context.Lock_context,
     &_POSIX_Barrier_Information
   );
 }
diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h
index 62ddbef..5888800 100644
--- a/cpukit/posix/include/rtems/posix/mqueueimpl.h
+++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h
@@ -114,7 +114,7 @@ RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get(
   _Thread_queue_Context_initialize( queue_context );
   return (POSIX_Message_queue_Control *) _Objects_Get(
     id,
-    &queue_context->Lock_context,
+    &queue_context->Lock_context.Lock_context,
     &_POSIX_Message_queue_Information
   );
 }
diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h
index fabde4d..12baa75 100644
--- a/cpukit/posix/include/rtems/posix/posixapi.h
+++ b/cpukit/posix/include/rtems/posix/posixapi.h
@@ -105,16 +105,22 @@ RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno(
   if ( id == NULL ) { \
     return NULL; \
   } \
-  the_object = \
-    _Objects_Get( (Objects_Id) *id, &queue_context->Lock_context, info ); \
+  the_object = _Objects_Get( \
+    (Objects_Id) *id, \
+    &queue_context->Lock_context.Lock_context, \
+    info \
+  ); \
   if ( the_object == NULL ) { \
     _Once_Lock(); \
     if ( *id == initializer ) { \
       init( id, NULL ); \
     } \
     _Once_Unlock(); \
-    the_object = \
-      _Objects_Get( (Objects_Id) *id, &queue_context->Lock_context, info ); \
+    the_object = _Objects_Get( \
+      (Objects_Id) *id, \
+      &queue_context->Lock_context.Lock_context, \
+      info \
+    ); \
   } \
   return (type *) the_object
 
diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
index 17d3f64..2bafbe9 100644
--- a/cpukit/posix/include/rtems/posix/semaphoreimpl.h
+++ b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
@@ -64,7 +64,7 @@ RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get(
   _Thread_queue_Context_initialize( queue_context );
   return (POSIX_Semaphore_Control *) _Objects_Get(
     (Objects_Id) *id,
-    &queue_context->Lock_context,
+    &queue_context->Lock_context.Lock_context,
     &_POSIX_Semaphore_Information
   );
 }
diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c
index 92793ed..52367f6 100644
--- a/cpukit/posix/src/condwaitsupp.c
+++ b/cpukit/posix/src/condwaitsupp.c
@@ -92,7 +92,9 @@ int _POSIX_Condition_variables_Wait_support(
 
   the_cond->mutex = *mutex;
 
-  cpu_self = _Thread_Dispatch_disable_critical( &queue_context.Lock_context );
+  cpu_self = _Thread_Dispatch_disable_critical(
+    &queue_context.Lock_context.Lock_context
+  );
   executing = _Per_CPU_Get_executing( cpu_self );
 
   if ( !already_timedout ) {
diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c
index dcb8178..f91a513 100644
--- a/cpukit/posix/src/mqueuerecvsupp.c
+++ b/cpukit/posix/src/mqueuerecvsupp.c
@@ -58,12 +58,12 @@ ssize_t _POSIX_Message_queue_Receive_support(
   }
 
   if ( ( the_mq->oflag & O_ACCMODE ) == O_WRONLY ) {
-    _ISR_lock_ISR_enable( &queue_context.Lock_context );
+    _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
     rtems_set_errno_and_return_minus_one( EBADF );
   }
 
   if ( msg_len < the_mq->Message_queue.maximum_message_size ) {
-    _ISR_lock_ISR_enable( &queue_context.Lock_context );
+    _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
     rtems_set_errno_and_return_minus_one( EMSGSIZE );
   }
 
diff --git a/cpukit/posix/src/mqueuesendsupp.c b/cpukit/posix/src/mqueuesendsupp.c
index 3fd51a4..c975a95 100644
--- a/cpukit/posix/src/mqueuesendsupp.c
+++ b/cpukit/posix/src/mqueuesendsupp.c
@@ -65,7 +65,7 @@ int _POSIX_Message_queue_Send_support(
   }
 
   if ( ( the_mq->oflag & O_ACCMODE ) == O_RDONLY ) {
-    _ISR_lock_ISR_enable( &queue_context.Lock_context );
+    _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
     rtems_set_errno_and_return_minus_one( EBADF );
   }
 
diff --git a/cpukit/posix/src/pthreadgetschedparam.c b/cpukit/posix/src/pthreadgetschedparam.c
index 1b7c731..38e0b4f 100644
--- a/cpukit/posix/src/pthreadgetschedparam.c
+++ b/cpukit/posix/src/pthreadgetschedparam.c
@@ -45,7 +45,7 @@ int pthread_getschedparam(
     return EINVAL;
   }
 
-  the_thread = _Thread_Get( thread, &queue_context.Lock_context );
+  the_thread = _Thread_Get( thread, &queue_context.Lock_context.Lock_context );
 
   if ( the_thread == NULL ) {
     return ESRCH;
diff --git a/cpukit/posix/src/pthreadjoin.c b/cpukit/posix/src/pthreadjoin.c
index 641031c..5ed0118 100644
--- a/cpukit/posix/src/pthreadjoin.c
+++ b/cpukit/posix/src/pthreadjoin.c
@@ -41,7 +41,7 @@ static int _POSIX_Threads_Join( pthread_t thread, void **value_ptr )
   _Thread_queue_Context_initialize( &queue_context );
   _Thread_queue_Context_set_expected_level( &queue_context, 1 );
   _Thread_queue_Context_set_no_timeout( &queue_context );
-  the_thread = _Thread_Get( thread, &queue_context.Lock_context );
+  the_thread = _Thread_Get( thread, &queue_context.Lock_context.Lock_context );
 
   if ( the_thread == NULL ) {
     return ESRCH;
@@ -51,22 +51,28 @@ static int _POSIX_Threads_Join( pthread_t thread, void **value_ptr )
   executing = _Per_CPU_Get_executing( cpu_self );
 
   if ( executing == the_thread ) {
-    _ISR_lock_ISR_enable( &queue_context.Lock_context );
+    _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
     return EDEADLK;
   }
 
-  _Thread_State_acquire_critical( the_thread, &queue_context.Lock_context );
+  _Thread_State_acquire_critical(
+    the_thread,
+    &queue_context.Lock_context.Lock_context
+  );
 
   if ( !_Thread_Is_joinable( the_thread ) ) {
-    _Thread_State_release( the_thread, &queue_context.Lock_context );
+    _Thread_State_release( the_thread, &queue_context.Lock_context.Lock_context );
     return EINVAL;
   }
 
   if ( _States_Is_waiting_for_join_at_exit( the_thread->current_state ) ) {
     value = the_thread->Life.exit_value;
     _Thread_Clear_state_locked( the_thread, STATES_WAITING_FOR_JOIN_AT_EXIT );
-    _Thread_Dispatch_disable_with_CPU( cpu_self, &queue_context.Lock_context );
-    _Thread_State_release( the_thread, &queue_context.Lock_context );
+    _Thread_Dispatch_disable_with_CPU(
+      cpu_self,
+      &queue_context.Lock_context.Lock_context
+    );
+    _Thread_State_release( the_thread, &queue_context.Lock_context.Lock_context );
     _Thread_Dispatch_enable( cpu_self );
   } else {
     _Thread_Join(
diff --git a/cpukit/posix/src/semunlink.c b/cpukit/posix/src/semunlink.c
index 6ba1df1..02fcdca 100644
--- a/cpukit/posix/src/semunlink.c
+++ b/cpukit/posix/src/semunlink.c
@@ -40,7 +40,7 @@ int sem_unlink(
 
   _POSIX_Semaphore_Namespace_remove( the_semaphore );
 
-  _ISR_lock_ISR_disable( &queue_context.Lock_context );
+  _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
   _CORE_semaphore_Acquire_critical( &the_semaphore->Semaphore, &queue_context );
   the_semaphore->linked = false;
   _POSIX_Semaphore_Delete( the_semaphore, &queue_context );
diff --git a/cpukit/rtems/include/rtems/rtems/barrierimpl.h b/cpukit/rtems/include/rtems/rtems/barrierimpl.h
index 91834b8..f0b53e0 100644
--- a/cpukit/rtems/include/rtems/rtems/barrierimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/barrierimpl.h
@@ -75,8 +75,11 @@ RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Get(
 )
 {
   _Thread_queue_Context_initialize( queue_context );
-  return (Barrier_Control *)
-    _Objects_Get( id, &queue_context->Lock_context, &_Barrier_Information );
+  return (Barrier_Control *) _Objects_Get(
+    id,
+    &queue_context->Lock_context.Lock_context,
+    &_Barrier_Information
+  );
 }
 
 /**@}*/
diff --git a/cpukit/rtems/include/rtems/rtems/messageimpl.h b/cpukit/rtems/include/rtems/rtems/messageimpl.h
index 9c1da39..df7cea6 100644
--- a/cpukit/rtems/include/rtems/rtems/messageimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/messageimpl.h
@@ -95,7 +95,7 @@ RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get(
   _Thread_queue_Context_initialize( queue_context );
   return (Message_queue_Control *) _Objects_Get(
     id,
-    &queue_context->Lock_context,
+    &queue_context->Lock_context.Lock_context,
     &_Message_queue_Information
   );
 }
diff --git a/cpukit/rtems/include/rtems/rtems/semimpl.h b/cpukit/rtems/include/rtems/rtems/semimpl.h
index 3259916..48b0a84 100644
--- a/cpukit/rtems/include/rtems/rtems/semimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/semimpl.h
@@ -99,7 +99,7 @@ RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get(
   _Thread_queue_Context_initialize( queue_context );
   return (Semaphore_Control *) _Objects_Get(
     id,
-    &queue_context->Lock_context,
+    &queue_context->Lock_context.Lock_context,
     &_Semaphore_Information
   );
 }
diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c
index 7d49542..77ecdd7 100644
--- a/cpukit/rtems/src/semcreate.c
+++ b/cpukit/rtems/src/semcreate.c
@@ -171,7 +171,7 @@ rtems_status_code rtems_semaphore_create(
           Thread_queue_Context queue_context;
 
           _Thread_queue_Context_initialize( &queue_context );
-          _ISR_lock_ISR_disable( &queue_context.Lock_context );
+          _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
           _CORE_mutex_Acquire_critical(
             &the_semaphore->Core_control.Mutex.Recursive.Mutex,
             &queue_context
diff --git a/cpukit/rtems/src/tasksetscheduler.c b/cpukit/rtems/src/tasksetscheduler.c
index 3546e6f..3a860a1 100644
--- a/cpukit/rtems/src/tasksetscheduler.c
+++ b/cpukit/rtems/src/tasksetscheduler.c
@@ -45,7 +45,7 @@ rtems_status_code rtems_task_set_scheduler(
   }
 
   _Thread_queue_Context_initialize( &queue_context );
-  the_thread = _Thread_Get( task_id, &queue_context.Lock_context );
+  the_thread = _Thread_Get( task_id, &queue_context.Lock_context.Lock_context );
 
   if ( the_thread == NULL ) {
 #if defined(RTEMS_MULTIPROCESSING)
@@ -57,7 +57,9 @@ rtems_status_code rtems_task_set_scheduler(
     return RTEMS_INVALID_ID;
   }
 
-  cpu_self = _Thread_Dispatch_disable_critical( &queue_context.Lock_context );
+  cpu_self = _Thread_Dispatch_disable_critical(
+    &queue_context.Lock_context.Lock_context
+  );
 
   _Thread_Wait_acquire_critical( the_thread, &queue_context );
   _Thread_State_acquire_critical( the_thread, &state_context );
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index 680c6d5..d40d91c 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -408,7 +408,9 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner(
     return STATUS_SUCCESSFUL;
   }
 
-  cpu_self = _Thread_Dispatch_disable_critical( &queue_context->Lock_context );
+  cpu_self = _Thread_Dispatch_disable_critical(
+    &queue_context->Lock_context.Lock_context
+  );
   _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context );
   _Thread_Raise_priority( owner, priority_ceiling );
   _Thread_Dispatch_enable( cpu_self );
@@ -524,7 +526,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Surrender(
       unblock,
       &the_mutex->Recursive.Mutex.Wait_queue.Queue,
       new_owner,
-      &queue_context->Lock_context
+      &queue_context->Lock_context.Lock_context
     );
   } else {
     _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context );
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index a2a25ae..70d4964 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -126,7 +126,9 @@ RTEMS_INLINE_ROUTINE void _MRSP_Claim_ownership(
   mrsp->initial_priority_of_owner = initial_priority;
   _Scheduler_Thread_change_help_state( new_owner, SCHEDULER_HELP_ACTIVE_OWNER );
 
-  cpu_self = _Thread_Dispatch_disable_critical( &queue_context->Lock_context );
+  cpu_self = _Thread_Dispatch_disable_critical(
+    &queue_context->Lock_context.Lock_context
+  );
   _MRSP_Release( mrsp, queue_context );
 
   _Thread_Raise_priority( new_owner, ceiling_priority );
@@ -207,7 +209,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Timeout( Watchdog_Control *watchdog )
   Thread_queue_Context queue_context;
 
   _Thread_queue_Context_initialize( &queue_context );
-  _ISR_lock_ISR_disable( &queue_context.Lock_context );
+  _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
   _MRSP_Acquire_critical( mrsp, &queue_context );
 
   if ( rival->status == MRSP_WAIT_FOR_OWNERSHIP ) {
@@ -269,7 +271,9 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership(
 
   _MRSP_Giant_release( &giant_lock_context );
 
-  cpu_self = _Thread_Dispatch_disable_critical( &queue_context->Lock_context );
+  cpu_self = _Thread_Dispatch_disable_critical(
+    &queue_context->Lock_context.Lock_context
+  );
   _MRSP_Release( mrsp, queue_context );
 
   _Thread_Raise_priority( executing, ceiling_priority );
@@ -329,7 +333,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize(
   Resource_Node *owner;
 
   if ( !priority_ok) {
-    _ISR_lock_ISR_enable( &queue_context->Lock_context );
+    _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
     return STATUS_MUTEX_CEILING_VIOLATED;
   }
 
@@ -376,7 +380,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender(
   ISR_lock_Context giant_lock_context;
 
   if ( _Resource_Get_owner( &mrsp->Resource ) != &executing->Resource_node ) {
-    _ISR_lock_ISR_enable( &queue_context->Lock_context );
+    _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
     return STATUS_NOT_OWNER;
   }
 
@@ -386,7 +390,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender(
       &executing->Resource_node
     )
   ) {
-    _ISR_lock_ISR_enable( &queue_context->Lock_context );
+    _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
     return STATUS_RELEASE_ORDER_VIOLATION;
   }
 
@@ -427,7 +431,9 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender(
 
   _MRSP_Giant_release( &giant_lock_context );
 
-  cpu_self = _Thread_Dispatch_disable_critical( &queue_context->Lock_context );
+  cpu_self = _Thread_Dispatch_disable_critical(
+    &queue_context->Lock_context.Lock_context
+  );
   _MRSP_Release( mrsp, queue_context );
 
   _MRSP_Restore_priority( executing, initial_priority );
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index cfa952e..1c043c3 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -1031,16 +1031,16 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default(
 
 #if defined(RTEMS_SMP)
 #define THREAD_QUEUE_CONTEXT_OF_REQUEST( node ) \
-  RTEMS_CONTAINER_OF( node, Thread_queue_Context, Wait.Gate.Node )
+  RTEMS_CONTAINER_OF( node, Thread_queue_Context, Lock_context.Wait.Gate.Node )
 
 RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request_locked(
-  Thread_Control       *the_thread,
-  Thread_queue_Context *queue_context
+  Thread_Control            *the_thread,
+  Thread_queue_Lock_context *queue_lock_context
 )
 {
   Chain_Node *first;
 
-  _Chain_Extract_unprotected( &queue_context->Wait.Gate.Node );
+  _Chain_Extract_unprotected( &queue_lock_context->Wait.Gate.Node );
   first = _Chain_First( &the_thread->Wait.Lock.Pending_requests );
 
   if ( first != _Chain_Tail( &the_thread->Wait.Lock.Pending_requests ) ) {
@@ -1049,25 +1049,25 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request_locked(
 }
 
 RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_queue_critical(
-  Thread_queue_Queue   *queue,
-  Thread_queue_Context *queue_context
+  Thread_queue_Queue        *queue,
+  Thread_queue_Lock_context *queue_lock_context
 )
 {
   _Thread_queue_Queue_acquire_critical(
     queue,
     &_Thread_Executing->Potpourri_stats,
-    &queue_context->Lock_context
+    &queue_lock_context->Lock_context
   );
 }
 
 RTEMS_INLINE_ROUTINE void _Thread_Wait_release_queue_critical(
-  Thread_queue_Queue   *queue,
-  Thread_queue_Context *queue_context
+  Thread_queue_Queue        *queue,
+  Thread_queue_Lock_context *queue_lock_context
 )
 {
   _Thread_queue_Queue_release_critical(
     queue,
-    &queue_context->Lock_context
+    &queue_lock_context->Lock_context
   );
 }
 #endif
@@ -1092,30 +1092,36 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_critical(
 
   _Thread_Wait_acquire_default_critical(
     the_thread,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 
   queue = the_thread->Wait.queue;
-  queue_context->Wait.queue = queue;
+  queue_context->Lock_context.Wait.queue = queue;
 
   if ( queue != NULL ) {
     _Thread_queue_Gate_add(
       &the_thread->Wait.Lock.Pending_requests,
-      &queue_context->Wait.Gate
+      &queue_context->Lock_context.Wait.Gate
     );
     _Thread_Wait_release_default_critical(
       the_thread,
-      &queue_context->Lock_context
+      &queue_context->Lock_context.Lock_context
     );
-    _Thread_Wait_acquire_queue_critical( queue, queue_context );
+    _Thread_Wait_acquire_queue_critical( queue, &queue_context->Lock_context );
 
-    if ( queue_context->Wait.queue == NULL ) {
-      _Thread_Wait_release_queue_critical( queue, queue_context );
+    if ( queue_context->Lock_context.Wait.queue == NULL ) {
+      _Thread_Wait_release_queue_critical(
+        queue,
+        &queue_context->Lock_context
+      );
       _Thread_Wait_acquire_default_critical(
         the_thread,
+        &queue_context->Lock_context.Lock_context
+      );
+      _Thread_Wait_remove_request_locked(
+        the_thread,
         &queue_context->Lock_context
       );
-      _Thread_Wait_remove_request_locked( the_thread, queue_context );
       _Assert( the_thread->Wait.queue == NULL );
     }
   }
@@ -1138,7 +1144,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire(
 )
 {
   _Thread_queue_Context_initialize( queue_context );
-  _ISR_lock_ISR_disable( &queue_context->Lock_context );
+  _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
   _Thread_Wait_acquire_critical( the_thread, queue_context );
 }
 
@@ -1160,21 +1166,25 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_critical(
 #if defined(RTEMS_SMP)
   Thread_queue_Queue *queue;
 
-  queue = queue_context->Wait.queue;
+  queue = queue_context->Lock_context.Wait.queue;
 
   if ( queue != NULL ) {
-    _Thread_Wait_release_queue_critical( queue, queue_context );
+    _Thread_Wait_release_queue_critical(
+      queue, &queue_context->Lock_context
+    );
     _Thread_Wait_acquire_default_critical(
       the_thread,
+      &queue_context->Lock_context.Lock_context
+    );
+    _Thread_Wait_remove_request_locked(
+      the_thread,
       &queue_context->Lock_context
     );
-
-    _Thread_Wait_remove_request_locked( the_thread, queue_context );
   }
 
   _Thread_Wait_release_default_critical(
     the_thread,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 #else
   (void) the_thread;
@@ -1196,7 +1206,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release(
 )
 {
   _Thread_Wait_release_critical( the_thread, queue_context );
-  _ISR_lock_ISR_enable( &queue_context->Lock_context );
+  _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
 }
 
 /**
@@ -1243,23 +1253,23 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_claim(
  * On other configurations, this function does nothing.
  *
  * @param[in] the_thread The thread.
- * @param[in] queue_context The thread queue context used for corresponding
- *   _Thread_Wait_acquire().
+ * @param[in] queue_lock_context The thread queue lock context used for
+ *   corresponding _Thread_Wait_acquire().
  */
 RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request(
-  Thread_Control       *the_thread,
-  Thread_queue_Context *queue_context
+  Thread_Control            *the_thread,
+  Thread_queue_Lock_context *queue_lock_context
 )
 {
 #if defined(RTEMS_SMP)
   ISR_lock_Context lock_context;
 
   _Thread_Wait_acquire_default( the_thread, &lock_context );
-  _Thread_Wait_remove_request_locked( the_thread, queue_context );
+  _Thread_Wait_remove_request_locked( the_thread, queue_lock_context );
   _Thread_Wait_release_default( the_thread, &lock_context );
 #else
   (void) the_thread;
-  (void) queue_context;
+  (void) queue_lock_context;
 #endif
 }
 
@@ -1294,7 +1304,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default(
       Thread_queue_Context *queue_context;
 
       queue_context = THREAD_QUEUE_CONTEXT_OF_REQUEST( node );
-      queue_context->Wait.queue = NULL;
+      queue_context->Lock_context.Wait.queue = NULL;
 
       node = _Chain_Next( node );
     } while ( node != tail );
@@ -1363,15 +1373,15 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel(
 
 #if defined(RTEMS_SMP)
   if ( queue != NULL ) {
-    _Assert( queue_context->Wait.queue == queue );
+    _Assert( queue_context->Lock_context.Wait.queue == queue );
 #endif
 
     ( *the_thread->Wait.operations->extract )( queue, the_thread );
     _Thread_Wait_restore_default( the_thread );
 
 #if defined(RTEMS_SMP)
-    _Assert( queue_context->Wait.queue == NULL );
-    queue_context->Wait.queue = queue;
+    _Assert( queue_context->Lock_context.Wait.queue == NULL );
+    queue_context->Lock_context.Wait.queue = queue;
   }
 #endif
 }
diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h
index 48e951e..a4ad082 100644
--- a/cpukit/score/include/rtems/score/threadq.h
+++ b/cpukit/score/include/rtems/score/threadq.h
@@ -95,11 +95,6 @@ typedef struct {
 } Thread_queue_Gate;
 #endif
 
-/**
- * @brief Thread queue context for the thread queue methods.
- *
- * @see _Thread_queue_Context_initialize().
- */
 typedef struct {
   /**
    * @brief The lock context for the thread queue acquire and release
@@ -107,50 +102,6 @@ typedef struct {
    */
   ISR_lock_Context Lock_context;
 
-  /**
-   * @brief The expected thread dispatch disable level for
-   * _Thread_queue_Enqueue_critical().
-   *
-   * In case the actual thread dispatch disable level is not equal to the
-   * expected level, then a fatal error occurs.
-   */
-  uint32_t expected_thread_dispatch_disable_level;
-
-  /**
-   * @brief The clock discipline for the interval timeout.
-   * Use WATCHDOG_NO_TIMEOUT to block indefinitely.
-   */
-  Watchdog_Discipline timeout_discipline;
-
-  /**
-   * @brief Interval to wait.
-   */
-  uint64_t timeout;
-
-  /**
-   * @brief Invoked in case of a detected deadlock.
-   *
-   * Must be initialized for _Thread_queue_Enqueue_critical() in case the
-   * thread queue may have an owner, e.g. for mutex objects.
-   *
-   * @see _Thread_queue_Context_set_deadlock_callout().
-   */
-  Thread_queue_Deadlock_callout deadlock_callout;
-
-#if defined(RTEMS_MULTIPROCESSING)
-  /**
-   * @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().
-   */
-  Thread_queue_MP_callout mp_callout;
-#endif
-
 #if defined(RTEMS_SMP)
   /**
    * @brief Data to support thread queue enqueue operations.
@@ -169,7 +120,7 @@ typedef struct {
     Thread_queue_Queue *queue;
   } Wait;
 #endif
-} Thread_queue_Context;
+} Thread_queue_Lock_context;
 
 #if defined(RTEMS_SMP)
 /**
@@ -205,14 +156,71 @@ typedef struct {
   Thread_Control *owner;
 
   /**
-   * @brief The queue context used to acquire the thread wait lock of the
+   * @brief The queue lock context used to acquire the thread wait lock of the
    * owner.
    */
-  Thread_queue_Context Queue_context;
+  Thread_queue_Lock_context Lock_context;
 } Thread_queue_Link;
 #endif
 
 /**
+ * @brief Thread queue context for the thread queue methods.
+ *
+ * @see _Thread_queue_Context_initialize().
+ */
+typedef struct {
+  /**
+   * @brief The lock context for the thread queue acquire and release
+   * operations.
+   */
+  Thread_queue_Lock_context Lock_context;
+
+  /**
+   * @brief The expected thread dispatch disable level for
+   * _Thread_queue_Enqueue_critical().
+   *
+   * In case the actual thread dispatch disable level is not equal to the
+   * expected level, then a fatal error occurs.
+   */
+  uint32_t expected_thread_dispatch_disable_level;
+
+  /**
+   * @brief The clock discipline for the interval timeout.
+   * Use WATCHDOG_NO_TIMEOUT to block indefinitely.
+   */
+  Watchdog_Discipline timeout_discipline;
+
+  /**
+   * @brief Interval to wait.
+   */
+  uint64_t timeout;
+
+  /**
+   * @brief Invoked in case of a detected deadlock.
+   *
+   * Must be initialized for _Thread_queue_Enqueue_critical() in case the
+   * thread queue may have an owner, e.g. for mutex objects.
+   *
+   * @see _Thread_queue_Context_set_deadlock_callout().
+   */
+  Thread_queue_Deadlock_callout deadlock_callout;
+
+#if defined(RTEMS_MULTIPROCESSING)
+  /**
+   * @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().
+   */
+  Thread_queue_MP_callout mp_callout;
+#endif
+} Thread_queue_Context;
+
+/**
  * @brief Thread priority queue.
  */
 typedef struct {
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index 641c618..977b0ce 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -372,7 +372,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(
 {
   _Thread_queue_Do_acquire_critical(
     the_thread_queue,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 }
 
@@ -381,7 +381,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire(
   Thread_queue_Context *queue_context
 )
 {
-  _ISR_lock_ISR_disable( &queue_context->Lock_context );
+  _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
   _Thread_queue_Acquire_critical( the_thread_queue, queue_context );
 }
 
@@ -422,7 +422,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical(
 {
   _Thread_queue_Do_release_critical(
     the_thread_queue,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 }
 
@@ -432,7 +432,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Release(
 )
 {
   _Thread_queue_Release_critical( the_thread_queue, queue_context );
-  _ISR_lock_ISR_enable( &queue_context->Lock_context );
+  _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
 }
 
 Thread_Control *_Thread_queue_Do_dequeue(
@@ -511,13 +511,13 @@ Thread_Control *_Thread_queue_Do_dequeue(
  *   Thread_Control       *executing;
  *
  *   _Thread_queue_Context_initialize( &queue_context );
- *   _Thread_queue_Acquire( &mutex->Queue, &queue_context.Lock_context );
+ *   _Thread_queue_Acquire( &mutex->Queue, queue_context );
  *
  *   executing = _Thread_Executing;
  *
  *   if ( mutex->owner == NULL ) {
  *     mutex->owner = executing;
- *     _Thread_queue_Release( &mutex->Queue, &queue_context.Lock_context );
+ *     _Thread_queue_Release( &mutex->Queue, queue_context );
  *   } else {
  *     _Thread_queue_Context_set_expected_level( &queue_context, 1 );
  *     _Thread_queue_Enqueue_critical(
diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c
index f69cfde..cf90a76 100644
--- a/cpukit/score/src/apimutexlock.c
+++ b/cpukit/score/src/apimutexlock.c
@@ -32,7 +32,7 @@ void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
     _Thread_Set_life_protection( THREAD_LIFE_PROTECTED );
 
   _Thread_queue_Context_initialize( &queue_context );
-  _ISR_lock_ISR_disable( &queue_context.Lock_context );
+  _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
   _Thread_queue_Context_set_no_timeout( &queue_context );
   _CORE_recursive_mutex_Seize(
     &the_mutex->Mutex,
diff --git a/cpukit/score/src/apimutexunlock.c b/cpukit/score/src/apimutexunlock.c
index 67188db..f04e47a 100644
--- a/cpukit/score/src/apimutexunlock.c
+++ b/cpukit/score/src/apimutexunlock.c
@@ -32,7 +32,7 @@ void _API_Mutex_Unlock( API_Mutex_Control *the_mutex )
   restore_thread_life_protection = the_mutex->Mutex.nest_level == 0;
 
   _Thread_queue_Context_initialize( &queue_context );
-  _ISR_lock_ISR_disable( &queue_context.Lock_context );
+  _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
   _CORE_recursive_mutex_Surrender(
     &the_mutex->Mutex,
     _Thread_Executing,
diff --git a/cpukit/score/src/condition.c b/cpukit/score/src/condition.c
index b9e14ad..36ef989 100644
--- a/cpukit/score/src/condition.c
+++ b/cpukit/score/src/condition.c
@@ -63,7 +63,7 @@ static Thread_Control *_Condition_Queue_acquire_critical(
   _Thread_queue_Queue_acquire_critical(
     &condition->Queue.Queue,
     &executing->Potpourri_stats,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 
   return executing;
@@ -76,7 +76,7 @@ static void _Condition_Queue_release(
 {
   _Thread_queue_Queue_release(
     &condition->Queue.Queue,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 }
 
@@ -91,7 +91,9 @@ static Per_CPU_Control *_Condition_Do_wait(
 
   condition = _Condition_Get( _condition );
   executing = _Condition_Queue_acquire_critical( condition, queue_context );
-  cpu_self = _Thread_Dispatch_disable_critical( &queue_context->Lock_context );
+  cpu_self = _Thread_Dispatch_disable_critical(
+    &queue_context->Lock_context.Lock_context
+  );
 
   _Thread_queue_Context_set_expected_level( queue_context, 2 );
   _Thread_queue_Enqueue_critical(
@@ -114,7 +116,7 @@ void _Condition_Wait(
   Per_CPU_Control      *cpu_self;
 
   _Thread_queue_Context_initialize( &queue_context );
-  _ISR_lock_ISR_disable( &queue_context.Lock_context );
+  _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
   _Thread_queue_Context_set_no_timeout( &queue_context );
   cpu_self = _Condition_Do_wait(
     _condition,
@@ -139,15 +141,15 @@ int _Condition_Wait_timed(
   Watchdog_Interval     ticks;
 
   _Thread_queue_Context_initialize( &queue_context );
-  _ISR_lock_ISR_disable( &queue_context.Lock_context );
+  _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
 
   switch ( _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ) ) {
     case TOD_ABSOLUTE_TIMEOUT_INVALID:
-      _ISR_lock_ISR_enable( &queue_context.Lock_context );
+      _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
       return EINVAL;
     case TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     case TOD_ABSOLUTE_TIMEOUT_IS_NOW:
-      _ISR_lock_ISR_enable( &queue_context.Lock_context );
+      _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
       return ETIMEDOUT;
     default:
       break;
@@ -175,7 +177,7 @@ void _Condition_Wait_recursive(
   unsigned int          nest_level;
 
   _Thread_queue_Context_initialize( &queue_context );
-  _ISR_lock_ISR_disable( &queue_context.Lock_context );
+  _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
   _Thread_queue_Context_set_no_timeout( &queue_context );
   cpu_self = _Condition_Do_wait( _condition, &queue_context );
 
@@ -201,15 +203,15 @@ int _Condition_Wait_recursive_timed(
   Watchdog_Interval      ticks;
 
   _Thread_queue_Context_initialize( &queue_context );
-  _ISR_lock_ISR_disable( &queue_context.Lock_context );
+  _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
 
   switch ( _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ) ) {
     case TOD_ABSOLUTE_TIMEOUT_INVALID:
-      _ISR_lock_ISR_enable( &queue_context.Lock_context );
+      _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
       return EINVAL;
     case TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST:
     case TOD_ABSOLUTE_TIMEOUT_IS_NOW:
-      _ISR_lock_ISR_enable( &queue_context.Lock_context );
+      _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
       return ETIMEDOUT;
     default:
       break;
@@ -261,7 +263,7 @@ static void _Condition_Wake( struct _Condition_Control *_condition, int count )
 
   condition = _Condition_Get( _condition );
   _Thread_queue_Context_initialize( &context.Base );
-  _ISR_lock_ISR_disable( &context.Base.Lock_context );
+  _ISR_lock_ISR_disable( &context.Base.Lock_context.Lock_context );
   _Condition_Queue_acquire_critical( condition, &context.Base );
 
   /*
diff --git a/cpukit/score/src/coremsgbroadcast.c b/cpukit/score/src/coremsgbroadcast.c
index f7579c2..ed92dbc 100644
--- a/cpukit/score/src/coremsgbroadcast.c
+++ b/cpukit/score/src/coremsgbroadcast.c
@@ -33,7 +33,7 @@ Status_Control _CORE_message_queue_Broadcast(
   uint32_t                    number_broadcasted;
 
   if ( size > the_message_queue->maximum_message_size ) {
-    _ISR_lock_ISR_enable( &queue_context->Lock_context );
+    _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
     return STATUS_MESSAGE_INVALID_SIZE;
   }
 
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index cfefc50..89b5c56 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -57,7 +57,7 @@ Status_Control _CORE_mutex_Seize_slow(
 #if defined(RTEMS_SMP)
   _Thread_queue_Context_set_expected_level( queue_context, 1 );
 #else
-  _ISR_lock_ISR_disable( &queue_context->Lock_context );
+  _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
   _CORE_mutex_Acquire_critical( the_mutex, queue_context );
   _Thread_queue_Context_set_expected_level( queue_context, 2 );
 #endif
diff --git a/cpukit/score/src/futex.c b/cpukit/score/src/futex.c
index 840101a..1989445 100644
--- a/cpukit/score/src/futex.c
+++ b/cpukit/score/src/futex.c
@@ -55,12 +55,12 @@ static Thread_Control *_Futex_Queue_acquire(
 {
   Thread_Control *executing;
 
-  _ISR_lock_ISR_disable( &queue_context->Lock_context );
+  _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
   executing = _Thread_Executing;
   _Thread_queue_Queue_acquire_critical(
     &futex->Queue.Queue,
     &executing->Potpourri_stats,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 
   return executing;
@@ -73,7 +73,7 @@ static void _Futex_Queue_release(
 {
   _Thread_queue_Queue_release(
     &futex->Queue.Queue,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 }
 
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index a562b29..87d90a6 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -335,7 +335,7 @@ void _MPCI_Receive_server(
 
     executing->receive_packet = NULL;
 
-    _ISR_lock_ISR_disable( &queue_context.Lock_context );
+    _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
     _CORE_semaphore_Seize(
       &_MPCI_Semaphore,
       MPCI_SEMAPHORE_TQ_OPERATIONS,
@@ -375,7 +375,7 @@ void _MPCI_Announce ( void )
 {
   Thread_queue_Context queue_context;
 
-  _ISR_lock_ISR_disable( &queue_context.Lock_context );
+  _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
   (void) _CORE_semaphore_Surrender(
     &_MPCI_Semaphore,
     MPCI_SEMAPHORE_TQ_OPERATIONS,
diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c
index b1311c0..bfa36ff 100644
--- a/cpukit/score/src/mutex.c
+++ b/cpukit/score/src/mutex.c
@@ -78,12 +78,12 @@ static Thread_Control *_Mutex_Queue_acquire(
 {
   Thread_Control *executing;
 
-  _ISR_lock_ISR_disable( &queue_context->Lock_context );
+  _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
   executing = _Thread_Executing;
   _Thread_queue_Queue_acquire_critical(
     &mutex->Queue.Queue,
     &executing->Potpourri_stats,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 
   return executing;
@@ -96,7 +96,7 @@ static void _Mutex_Queue_release(
 {
   _Thread_queue_Queue_release(
     &mutex->Queue.Queue,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 }
 
diff --git a/cpukit/score/src/semaphore.c b/cpukit/score/src/semaphore.c
index 72cb1c7..be7d685 100644
--- a/cpukit/score/src/semaphore.c
+++ b/cpukit/score/src/semaphore.c
@@ -62,12 +62,12 @@ static Thread_Control *_Semaphore_Queue_acquire(
 {
   Thread_Control *executing;
 
-  _ISR_lock_ISR_disable( &queue_context->Lock_context );
+  _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
   executing = _Thread_Executing;
   _Thread_queue_Queue_acquire_critical(
     &sem->Queue.Queue,
     &executing->Potpourri_stats,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 
   return executing;
@@ -80,7 +80,7 @@ static void _Semaphore_Queue_release(
 {
   _Thread_queue_Queue_release(
     &sem->Queue.Queue,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 }
 
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 81b3948..f16dff0 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -184,10 +184,10 @@ static void _Thread_queue_Path_release( Thread_queue_Path *path )
 
     link = THREAD_QUEUE_LINK_OF_PATH_NODE( node );
 
-    if ( link->Queue_context.Wait.queue == NULL ) {
+    if ( link->Lock_context.Wait.queue == NULL ) {
       _Thread_Wait_release_default_critical(
         link->owner,
-        &link->Queue_context.Lock_context
+        &link->Lock_context.Lock_context
       );
 
       node = _Chain_Previous( node );
@@ -199,14 +199,14 @@ static void _Thread_queue_Path_release( Thread_queue_Path *path )
     while ( head != node ) {
       /* The other links have an owner which waits on a thread queue */
       link = THREAD_QUEUE_LINK_OF_PATH_NODE( node );
-      _Assert( link->Queue_context.Wait.queue != NULL );
+      _Assert( link->Lock_context.Wait.queue != NULL );
 
       _Thread_queue_Link_remove( link );
       _Thread_Wait_release_queue_critical(
-        link->Queue_context.Wait.queue,
-        &link->Queue_context
+        link->Lock_context.Wait.queue,
+        &link->Lock_context
       );
-      _Thread_Wait_remove_request( link->owner, &link->Queue_context );
+      _Thread_Wait_remove_request( link->owner, &link->Lock_context );
 
       node = _Chain_Previous( node );
 #if defined(RTEMS_DEBUG)
@@ -253,7 +253,7 @@ static bool _Thread_queue_Path_acquire(
 
   _RBTree_Initialize_node( &path->Start.Registry_node );
   _Chain_Initialize_node( &path->Start.Path_node );
-  _Thread_queue_Context_initialize( &path->Start.Queue_context );
+  _Chain_Initialize_node( &path->Start.Lock_context.Wait.Gate.Node );
   link = &path->Start;
 
   do {
@@ -262,37 +262,37 @@ static bool _Thread_queue_Path_acquire(
 
     _Thread_Wait_acquire_default_critical(
       owner,
-      &link->Queue_context.Lock_context
+      &link->Lock_context.Lock_context
     );
 
     target = owner->Wait.queue;
-    link->Queue_context.Wait.queue = target;
+    link->Lock_context.Wait.queue = target;
 
     if ( target != NULL ) {
       if ( _Thread_queue_Link_add( link, queue, target ) ) {
         _Thread_queue_Gate_add(
           &owner->Wait.Lock.Pending_requests,
-          &link->Queue_context.Wait.Gate
+          &link->Lock_context.Wait.Gate
         );
         _Thread_Wait_release_default_critical(
           owner,
-          &link->Queue_context.Lock_context
+          &link->Lock_context.Lock_context
         );
-        _Thread_Wait_acquire_queue_critical( target, &link->Queue_context );
+        _Thread_Wait_acquire_queue_critical( target, &link->Lock_context );
 
-        if ( link->Queue_context.Wait.queue == NULL ) {
+        if ( link->Lock_context.Wait.queue == NULL ) {
           _Thread_queue_Link_remove( link );
-          _Thread_Wait_release_queue_critical( target, &link->Queue_context );
+          _Thread_Wait_release_queue_critical( target, &link->Lock_context );
           _Thread_Wait_acquire_default_critical(
             owner,
-            &link->Queue_context.Lock_context
+            &link->Lock_context.Lock_context
           );
-          _Thread_Wait_remove_request_locked( owner, &link->Queue_context );
+          _Thread_Wait_remove_request_locked( owner, &link->Lock_context );
           _Assert( owner->Wait.queue == NULL );
           return true;
         }
       } else {
-        link->Queue_context.Wait.queue = NULL;
+        link->Lock_context.Wait.queue = NULL;
         _Thread_queue_Path_release( path );
         return false;
       }
@@ -359,7 +359,7 @@ void _Thread_queue_Enqueue_critical(
 
   if ( !_Thread_queue_Path_acquire( the_thread, queue, &path ) ) {
     _Thread_Wait_restore_default( the_thread );
-    _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+    _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
     _Thread_Wait_tranquilize( the_thread );
     ( *queue_context->deadlock_callout )( the_thread );
     return;
@@ -371,8 +371,10 @@ void _Thread_queue_Enqueue_critical(
 
   the_thread->Wait.return_code = STATUS_SUCCESSFUL;
   _Thread_Wait_flags_set( the_thread, THREAD_QUEUE_INTEND_TO_BLOCK );
-  cpu_self = _Thread_Dispatch_disable_critical( &queue_context->Lock_context );
-  _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+  cpu_self = _Thread_Dispatch_disable_critical(
+    &queue_context->Lock_context.Lock_context
+  );
+  _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
 
   if (
     cpu_self->thread_dispatch_disable_level
@@ -544,7 +546,7 @@ void _Thread_queue_Extract_critical(
     unblock,
     queue,
     the_thread,
-    &queue_context->Lock_context
+    &queue_context->Lock_context.Lock_context
   );
 }
 
@@ -561,7 +563,7 @@ void _Thread_queue_Extract( Thread_Control *the_thread )
   if ( queue != NULL ) {
     bool unblock;
 
-    _Thread_Wait_remove_request( the_thread, &queue_context );
+    _Thread_Wait_remove_request( the_thread, &queue_context.Lock_context );
     _Thread_queue_Context_set_MP_callout(
       &queue_context,
       _Thread_queue_MP_callout_do_nothing
@@ -576,7 +578,7 @@ void _Thread_queue_Extract( Thread_Control *the_thread )
       unblock,
       queue,
       the_thread,
-      &queue_context.Lock_context
+      &queue_context.Lock_context.Lock_context
     );
   } else {
     _Thread_Wait_release( the_thread, &queue_context );
@@ -612,10 +614,10 @@ void _Thread_queue_Surrender(
       unblock,
       queue,
       new_owner,
-      &queue_context->Lock_context
+      &queue_context->Lock_context.Lock_context
     );
   } else {
-    _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+    _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
   }
 
   if ( !keep_priority ) {
diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c
index df2859d..835858d 100644
--- a/cpukit/score/src/threadqflush.c
+++ b/cpukit/score/src/threadqflush.c
@@ -109,9 +109,9 @@ size_t _Thread_queue_Flush_critical(
     Per_CPU_Control *cpu_self;
 
     cpu_self = _Thread_Dispatch_disable_critical(
-      &queue_context->Lock_context
+      &queue_context->Lock_context.Lock_context
     );
-    _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+    _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
 
     do {
       Thread_Control *the_thread;
@@ -126,7 +126,7 @@ size_t _Thread_queue_Flush_critical(
 
     _Thread_Dispatch_enable( cpu_self );
   } else {
-    _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+    _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
   }
 
   return flushed;
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index b7804a5..e963c73 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -536,7 +536,7 @@ void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing )
   _Thread_queue_Context_initialize( &queue_context );
   _Thread_queue_Context_set_expected_level( &queue_context, 2 );
   _Thread_queue_Context_set_no_timeout( &queue_context );
-  _Thread_State_acquire( the_thread, &queue_context.Lock_context );
+  _Thread_State_acquire( the_thread, &queue_context.Lock_context.Lock_context );
   _Thread_Join(
     the_thread,
     STATES_WAITING_FOR_JOIN,
diff --git a/testsuites/sptests/spintrcritical22/init.c b/testsuites/sptests/spintrcritical22/init.c
index 56d7837..7412bde 100644
--- a/testsuites/sptests/spintrcritical22/init.c
+++ b/testsuites/sptests/spintrcritical22/init.c
@@ -38,7 +38,7 @@ static Semaphore_Control *get_semaphore_control(rtems_id id)
 
   sem = _Semaphore_Get(id, &queue_context);
   rtems_test_assert(sem != NULL);
-  _ISR_lock_ISR_enable(&queue_context.Lock_context);
+  _ISR_lock_ISR_enable(&queue_context.Lock_context.Lock_context);
 
   return sem;
 }
diff --git a/testsuites/tmtests/tm26/task1.c b/testsuites/tmtests/tm26/task1.c
index 38fb0ea..0e52d3d 100644
--- a/testsuites/tmtests/tm26/task1.c
+++ b/testsuites/tmtests/tm26/task1.c
@@ -515,7 +515,7 @@ void complete_test( void )
   benchmark_timer_initialize();
     for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
       (void) _Semaphore_Get( Semaphore_id, &queue_context );
-      _ISR_lock_ISR_enable( &queue_context.Lock_context );
+      _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
     }
   semaphore_get_time = benchmark_timer_read();
 
-- 
1.8.4.5





More information about the devel mailing list