On Tue, Jun 21, 2016 at 1:48 AM, Sebastian Huber
<sebastian.hu...@embedded-brains.de> wrote:
>
>
> On 16/06/16 08:09, Sebastian Huber wrote:
>>>
>>> diff --git a/cpukit/score/include/rtems/score/threadqimpl.h
>>> b/cpukit/score/include/rtems/score/threadqimpl.h
>>> index 73d4de2..f59a334 100644
>>> --- a/cpukit/score/include/rtems/score/threadqimpl.h
>>> +++ b/cpukit/score/include/rtems/score/threadqimpl.h
>>> @@ -349,6 +349,7 @@ Thread_Control *_Thread_queue_Do_dequeue(
>>>    *       executing,
>>>    *       STATES_WAITING_FOR_MUTEX,
>>>    *       WATCHDOG_NO_TIMEOUT,
>>> + *       WATCHDOG_RELATIVE,
>>>    *       0,
>>>    *       &queue_context
>>>    *     );
>>> @@ -362,6 +363,7 @@ Thread_Control *_Thread_queue_Do_dequeue(
>>>    * @param[in] state The new state of the thread.
>>>    * @param[in] timeout Interval to wait.  Use WATCHDOG_NO_TIMEOUT to
>>> block
>>>    * potentially forever.
>>> + * @param[in] clock The kind of clock used for the interval.
>>>    * @param[in] queue_context The thread queue context of the lock
>>> acquire.
>>>    */
>>>   void _Thread_queue_Enqueue_critical(
>>> @@ -370,6 +372,7 @@ void _Thread_queue_Enqueue_critical(
>>>     Thread_Control                *the_thread,
>>>     States_Control                 state,
>>>     Watchdog_Interval              timeout,
>>> +  Watchdog_Clock                 clock,
>>>     Thread_queue_Context          *queue_context
>>>   );
>>
>>
>> We already have a lot of parameters for the
>> _Thread_queue_Enqueue_critical(). I would rather move the timeout parameters
>> to the queue_context, since this is more efficient.
>>
>> The Watchdog_Interval is 32-bit, thus not suitable for the absolute
>> timeouts.
>>
>> A value of 0 is valid for absolute timeouts, see what happens if you get
>> that wrong
>>
>>
>> https://www.wired.com/2016/02/dont-set-your-iphone-back-to-1970-no-matter-what/
>>
>> So, I would move the WATCHDOG_NO_TIMEOUT to your new Watchdog_Clock.
>>
>> [...]
>
>
> From IRC log:
>
> [19:44] <gedare> sebhub: Does it make sense to you to redefine
> Watchdog_Interval as a struct containing a union for the interval and an
> enum for the Clock "Discipline" (relative/absolute)?
> [19:45] <gedare> ^the union for uint32_t relative, uint64_t absolute--or
> else we make all intervals 64-bit
>
> No, I would not change Watchdog_Interval. We should keep the ticks based
> services as is. The problem is that _Thread_queue_Enqueue_critical() doesn't
> support absolute timeouts currently. I would do something like the attached.
>
> We have
>
> void _Thread_queue_Enqueue_critical(
>   Thread_queue_Queue            *queue,
>   const Thread_queue_Operations *operations,
>   Thread_Control                *the_thread,
>   States_Control                 state,
>   Thread_queue_Context          *queue_context
> )
> {
>   Per_CPU_Control *cpu_self;
>   bool             success;
>
> #if defined(RTEMS_MULTIPROCESSING)
>   if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet ) {
>     the_thread = _Thread_MP_Allocate_proxy( state );
>   }
> #endif
>
>   _Thread_Lock_set( the_thread, &queue->Lock );
>
>   the_thread->Wait.return_code = STATUS_SUCCESSFUL;
>   _Thread_Wait_set_queue( the_thread, queue );
>   _Thread_Wait_set_operations( the_thread, operations );
>
>   ( *operations->enqueue )( queue, the_thread );
>
> Thus, we would have to store the timeout related parameters to the stack
> anyway, since ( *operations->enqueue )( queue, the_thread ) is a function
> call which cannot be optimized way (except maybe through link-time
> optimization). So, there is no overhead due to the use of the queue context.
>
Thanks, that makes sense. I mocked together the changes to put the
timeout parameters into the context. I will work on adding the little
bit needed to use 64-bit intervals for absolute.

Do you have a preference between "Watchdog_Discipline" and
"Watchdog_Clock"? I think Discipline may be nicer.

I did not put the initialization of the timeout parameters to a
default, instead I made each producer of a threadq_enqueue to
explicitly set the parameters. Perhaps a sane default of NO_TIMEOUT is
good, and will reduce the size of my patch.

Tomorrow I'll work on cleaning this up some more. Wrapping the
WATCHDOG_NO_TIMEOUT in the Watchdog_Discipline makes the structure no
longer match with the Per_CPU_Watchdog_index values. So a little bit
of massaging has to be done there.
From dc0eda684c9cde7132ea82f58209b8a3fb241901 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <ged...@rtems.org>
Date: Mon, 20 Jun 2016 15:43:53 -0400
Subject: [PATCH 3/3] score: move timeout parameters into Thread_queue_Context.

updates #2732.
---
 cpukit/libnetworking/rtems/rtems_glue.c            |  3 +-
 cpukit/posix/src/condwaitsupp.c                    |  4 +-
 cpukit/posix/src/mqueuerecvsupp.c                  |  3 +-
 cpukit/posix/src/mqueuesendsupp.c                  |  3 +-
 cpukit/posix/src/mutexlocksupp.c                   |  5 +--
 cpukit/posix/src/pbarrierwait.c                    |  3 +-
 cpukit/posix/src/prwlockrdlock.c                   |  3 +-
 cpukit/posix/src/prwlocktimedrdlock.c              |  3 +-
 cpukit/posix/src/prwlocktimedwrlock.c              |  3 +-
 cpukit/posix/src/prwlocktryrdlock.c                |  1 -
 cpukit/posix/src/prwlocktrywrlock.c                |  1 -
 cpukit/posix/src/prwlockwrlock.c                   |  3 +-
 cpukit/posix/src/pthreadjoin.c                     |  2 +
 cpukit/posix/src/semaphorewaitsupp.c               |  3 +-
 cpukit/posix/src/sigtimedwait.c                    |  4 +-
 cpukit/rtems/src/barrierwait.c                     |  3 +-
 cpukit/rtems/src/msgqreceive.c                     |  3 +-
 cpukit/rtems/src/msgqsend.c                        |  1 -
 cpukit/rtems/src/msgqurgent.c                      |  1 -
 cpukit/rtems/src/semobtain.c                       |  8 ++--
 cpukit/score/include/rtems/score/corebarrierimpl.h |  5 ---
 cpukit/score/include/rtems/score/coremsgimpl.h     | 10 -----
 cpukit/score/include/rtems/score/coremuteximpl.h   |  8 ----
 cpukit/score/include/rtems/score/corerwlockimpl.h  |  6 ---
 cpukit/score/include/rtems/score/coresemimpl.h     |  4 --
 cpukit/score/include/rtems/score/mrspimpl.h        |  7 ++--
 cpukit/score/include/rtems/score/threadq.h         | 11 ++++++
 cpukit/score/include/rtems/score/threadqimpl.h     | 43 ++++++++++++++++++----
 cpukit/score/src/apimutexlock.c                    |  4 +-
 cpukit/score/src/condition.c                       | 22 +++++++----
 cpukit/score/src/corebarrierwait.c                 |  3 --
 cpukit/score/src/coremsgseize.c                    |  3 --
 cpukit/score/src/coremsgsubmit.c                   |  3 --
 cpukit/score/src/coremutexseize.c                  |  6 ---
 cpukit/score/src/corerwlockobtainread.c            |  3 --
 cpukit/score/src/corerwlockobtainwrite.c           |  3 --
 cpukit/score/src/futex.c                           |  4 +-
 cpukit/score/src/mutex.c                           | 25 ++++++-------
 cpukit/score/src/semaphore.c                       |  4 +-
 cpukit/score/src/threadqenqueue.c                  |  4 +-
 cpukit/score/src/threadrestart.c                   |  4 +-
 41 files changed, 120 insertions(+), 122 deletions(-)

diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c
index e9b371f..7cfc45c 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -377,11 +377,12 @@ rtems_bsdnet_semaphore_obtain (void)
 		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);
+        _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+        _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
 	status = _CORE_recursive_mutex_Seize (
 		&the_networkSemaphore->Core_control.Mutex.Recursive,
 		_Thread_Executing,
 		true,			/* wait */
-		WATCHDOG_NO_TIMEOUT,	/* forever */
 		_CORE_recursive_mutex_Seize_nested,
 		&queue_context
 	);
diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c
index 08f96d1..0108252 100644
--- a/cpukit/posix/src/condwaitsupp.c
+++ b/cpukit/posix/src/condwaitsupp.c
@@ -68,13 +68,13 @@ int _POSIX_Condition_variables_Wait_support(
 
   if ( !already_timedout ) {
     _Thread_queue_Context_set_expected_level( &queue_context, 2 );
+    _Thread_queue_Context_set_timeout( &queue_context, timeout );
+    _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
     _Thread_queue_Enqueue_critical(
       &the_cond->Wait_queue.Queue,
       POSIX_CONDITION_VARIABLES_TQ_OPERATIONS,
       executing,
       STATES_WAITING_FOR_CONDITION_VARIABLE,
-      timeout,
-      WATCHDOG_RELATIVE,
       &queue_context
     );
   } else {
diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c
index cbb0dc0..6ec0ca5 100644
--- a/cpukit/posix/src/mqueuerecvsupp.c
+++ b/cpukit/posix/src/mqueuerecvsupp.c
@@ -97,13 +97,14 @@ ssize_t _POSIX_Message_queue_Receive_support(
    *  Now perform the actual message receive
    */
   executing = _Thread_Executing;
+  _Thread_queue_Context_set_timeout( &queue_context, timeout );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_message_queue_Seize(
     &the_mq->Message_queue,
     executing,
     msg_ptr,
     &length_out,
     do_wait,
-    timeout,
     &queue_context
   );
 
diff --git a/cpukit/posix/src/mqueuesendsupp.c b/cpukit/posix/src/mqueuesendsupp.c
index 9785fb2..87fc10a 100644
--- a/cpukit/posix/src/mqueuesendsupp.c
+++ b/cpukit/posix/src/mqueuesendsupp.c
@@ -92,6 +92,8 @@ int _POSIX_Message_queue_Send_support(
    *  Now perform the actual message receive
    */
   executing = _Thread_Executing;
+  _Thread_queue_Context_set_timeout( &queue_context, timeout );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_message_queue_Submit(
     &the_mq->Message_queue,
     executing,
@@ -99,7 +101,6 @@ int _POSIX_Message_queue_Send_support(
     msg_len,
     _POSIX_Message_queue_Priority_to_core( msg_prio ),
     do_wait,
-    timeout,
     &queue_context
   );
   return _POSIX_Zero_or_minus_one_plus_errno( status );
diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c
index d3d07f6..0831da5 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -63,6 +63,8 @@ int _POSIX_Mutex_Lock_support(
   }
 
   executing = _Thread_Executing;
+  _Thread_queue_Context_set_timeout( &queue_context, timeout );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
 
   switch ( the_mutex->protocol ) {
     case POSIX_MUTEX_PRIORITY_CEILING:
@@ -70,7 +72,6 @@ int _POSIX_Mutex_Lock_support(
         &the_mutex->Mutex,
         executing,
         wait,
-        timeout,
         _POSIX_Mutex_Lock_nested,
         &queue_context
       );
@@ -81,7 +82,6 @@ int _POSIX_Mutex_Lock_support(
         POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
         executing,
         wait,
-        timeout,
         _POSIX_Mutex_Lock_nested,
         &queue_context
       );
@@ -92,7 +92,6 @@ int _POSIX_Mutex_Lock_support(
         &the_mutex->Mutex.Recursive,
         executing,
         wait,
-        timeout,
         _POSIX_Mutex_Lock_nested,
         &queue_context
       );
diff --git a/cpukit/posix/src/pbarrierwait.c b/cpukit/posix/src/pbarrierwait.c
index 0197e46..26ccb76 100644
--- a/cpukit/posix/src/pbarrierwait.c
+++ b/cpukit/posix/src/pbarrierwait.c
@@ -41,11 +41,12 @@ int pthread_barrier_wait(
     return EINVAL;
   }
 
+  _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_barrier_Seize(
     &the_barrier->Barrier,
     _Thread_Executing,
     true,
-    WATCHDOG_NO_TIMEOUT,
     &queue_context
   );
   return _POSIX_Get_error( status );
diff --git a/cpukit/posix/src/prwlockrdlock.c b/cpukit/posix/src/prwlockrdlock.c
index 295148e..b160798 100644
--- a/cpukit/posix/src/prwlockrdlock.c
+++ b/cpukit/posix/src/prwlockrdlock.c
@@ -35,11 +35,12 @@ int pthread_rwlock_rdlock(
     return EINVAL;
   }
 
+  _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_RWLock_Seize_for_reading(
     &the_rwlock->RWLock,
     _Thread_Executing,
     true,                 /* we are willing to wait forever */
-    0,
     &queue_context
   );
   return _POSIX_Get_error( status );
diff --git a/cpukit/posix/src/prwlocktimedrdlock.c b/cpukit/posix/src/prwlocktimedrdlock.c
index 1c10590..b5de94e 100644
--- a/cpukit/posix/src/prwlocktimedrdlock.c
+++ b/cpukit/posix/src/prwlocktimedrdlock.c
@@ -56,11 +56,12 @@ int pthread_rwlock_timedrdlock(
     return EINVAL;
   }
 
+  _Thread_queue_Context_set_timeout( &queue_context, ticks );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_RWLock_Seize_for_reading(
     &the_rwlock->RWLock,
     _Thread_Executing,
     do_wait,
-    ticks,
     &queue_context
   );
 
diff --git a/cpukit/posix/src/prwlocktimedwrlock.c b/cpukit/posix/src/prwlocktimedwrlock.c
index 8080a8a..420c4c2 100644
--- a/cpukit/posix/src/prwlocktimedwrlock.c
+++ b/cpukit/posix/src/prwlocktimedwrlock.c
@@ -58,11 +58,12 @@ int pthread_rwlock_timedwrlock(
     return EINVAL;
   }
 
+  _Thread_queue_Context_set_timeout( &queue_context, ticks );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_RWLock_Seize_for_writing(
     &the_rwlock->RWLock,
     _Thread_Executing,
     do_wait,
-    ticks,
     &queue_context
   );
 
diff --git a/cpukit/posix/src/prwlocktryrdlock.c b/cpukit/posix/src/prwlocktryrdlock.c
index 5c6931e..052f1b0 100644
--- a/cpukit/posix/src/prwlocktryrdlock.c
+++ b/cpukit/posix/src/prwlocktryrdlock.c
@@ -39,7 +39,6 @@ int pthread_rwlock_tryrdlock(
     &the_rwlock->RWLock,
     _Thread_Executing,
     false,                  /* do not wait for the rwlock */
-    0,
     &queue_context
   );
   return _POSIX_Get_error( status );
diff --git a/cpukit/posix/src/prwlocktrywrlock.c b/cpukit/posix/src/prwlocktrywrlock.c
index 1181382..976e7a8 100644
--- a/cpukit/posix/src/prwlocktrywrlock.c
+++ b/cpukit/posix/src/prwlocktrywrlock.c
@@ -39,7 +39,6 @@ int pthread_rwlock_trywrlock(
     &the_rwlock->RWLock,
     _Thread_Executing,
     false,                 /* we are not willing to wait */
-    0,
     &queue_context
   );
   return _POSIX_Get_error( status );
diff --git a/cpukit/posix/src/prwlockwrlock.c b/cpukit/posix/src/prwlockwrlock.c
index 4592aaa..42eeca8 100644
--- a/cpukit/posix/src/prwlockwrlock.c
+++ b/cpukit/posix/src/prwlockwrlock.c
@@ -39,11 +39,12 @@ int pthread_rwlock_wrlock(
     return EINVAL;
   }
 
+  _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_RWLock_Seize_for_writing(
     &the_rwlock->RWLock,
     _Thread_Executing,
     true,          /* do not timeout -- wait forever */
-    0,
     &queue_context
   );
   return _POSIX_Get_error( status );
diff --git a/cpukit/posix/src/pthreadjoin.c b/cpukit/posix/src/pthreadjoin.c
index 86b8051..67e4ff9 100644
--- a/cpukit/posix/src/pthreadjoin.c
+++ b/cpukit/posix/src/pthreadjoin.c
@@ -40,6 +40,8 @@ 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_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   the_thread = _Thread_Get( thread, &queue_context.Lock_context );
 
   if ( the_thread == NULL ) {
diff --git a/cpukit/posix/src/semaphorewaitsupp.c b/cpukit/posix/src/semaphorewaitsupp.c
index 9ba8d55..95bf884 100644
--- a/cpukit/posix/src/semaphorewaitsupp.c
+++ b/cpukit/posix/src/semaphorewaitsupp.c
@@ -41,12 +41,13 @@ int _POSIX_Semaphore_Wait_support(
     rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
+  _Thread_queue_Context_set_timeout( &queue_context, timeout );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_semaphore_Seize(
     &the_semaphore->Semaphore,
     POSIX_SEMAPHORE_TQ_OPERATIONS,
     _Thread_Executing,
     blocking,
-    timeout,
     &queue_context
   );
   return _POSIX_Zero_or_minus_one_plus_errno( status );
diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c
index 1bdb278..cf97235 100644
--- a/cpukit/posix/src/sigtimedwait.c
+++ b/cpukit/posix/src/sigtimedwait.c
@@ -153,13 +153,13 @@ int sigtimedwait(
   executing->Wait.option          = *set;
   executing->Wait.return_argument = the_info;
   _Thread_queue_Context_set_expected_level( &queue_context, 1 );
+  _Thread_queue_Context_set_timeout( &queue_context, interval );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   _Thread_queue_Enqueue_critical(
     &_POSIX_signals_Wait_queue.Queue,
     POSIX_SIGNALS_TQ_OPERATIONS,
     executing,
     STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL,
-    interval,
-    WATCHDOG_RELATIVE,
     &queue_context
   );
 
diff --git a/cpukit/rtems/src/barrierwait.c b/cpukit/rtems/src/barrierwait.c
index 5f1f023..e965f46 100644
--- a/cpukit/rtems/src/barrierwait.c
+++ b/cpukit/rtems/src/barrierwait.c
@@ -38,11 +38,12 @@ rtems_status_code rtems_barrier_wait(
     return RTEMS_INVALID_ID;
   }
 
+  _Thread_queue_Context_set_timeout( &queue_context, timeout );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_barrier_Seize(
     &the_barrier->Barrier,
     _Thread_Executing,
     true,
-    timeout,
     &queue_context
   );
   return _Status_Get( status );
diff --git a/cpukit/rtems/src/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c
index 75c15be..695685f 100644
--- a/cpukit/rtems/src/msgqreceive.c
+++ b/cpukit/rtems/src/msgqreceive.c
@@ -61,13 +61,14 @@ rtems_status_code rtems_message_queue_receive(
   );
 
   executing = _Thread_Executing;
+  _Thread_queue_Context_set_timeout( &queue_context, timeout );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   status = _CORE_message_queue_Seize(
     &the_message_queue->message_queue,
     executing,
     buffer,
     size,
     !_Options_Is_no_wait( option_set ),
-    timeout,
     &queue_context
   );
   return _Status_Get( status );
diff --git a/cpukit/rtems/src/msgqsend.c b/cpukit/rtems/src/msgqsend.c
index 7968281..1fab4b0 100644
--- a/cpukit/rtems/src/msgqsend.c
+++ b/cpukit/rtems/src/msgqsend.c
@@ -58,7 +58,6 @@ rtems_status_code rtems_message_queue_send(
     buffer,
     size,
     false,   /* sender does not block */
-    0,       /* no timeout */
     &queue_context
   );
   return _Status_Get( status );
diff --git a/cpukit/rtems/src/msgqurgent.c b/cpukit/rtems/src/msgqurgent.c
index 6c6379d..4756da4 100644
--- a/cpukit/rtems/src/msgqurgent.c
+++ b/cpukit/rtems/src/msgqurgent.c
@@ -58,7 +58,6 @@ rtems_status_code rtems_message_queue_urgent(
     buffer,
     size,
     false,   /* sender does not block */
-    0,       /* no timeout */
     &queue_context
   );
   return _Status_Get( status );
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 0e5330a..3508c45 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -69,13 +69,15 @@ rtems_status_code rtems_semaphore_obtain(
   executing = _Thread_Executing;
   wait = !_Options_Is_no_wait( option_set );
 
+  _Thread_queue_Context_set_timeout( &queue_context, timeout );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
+
   switch ( the_semaphore->variant ) {
     case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
       status = _CORE_recursive_mutex_Seize(
         &the_semaphore->Core_control.Mutex.Recursive,
         executing,
         wait,
-        timeout,
         _CORE_recursive_mutex_Seize_nested,
         &queue_context
       );
@@ -85,7 +87,6 @@ rtems_status_code rtems_semaphore_obtain(
         &the_semaphore->Core_control.Mutex,
         executing,
         wait,
-        timeout,
         _CORE_recursive_mutex_Seize_nested,
         &queue_context
       );
@@ -96,7 +97,6 @@ rtems_status_code rtems_semaphore_obtain(
         _Semaphore_Get_operations( the_semaphore ),
         executing,
         wait,
-        timeout,
         _CORE_recursive_mutex_Seize_nested,
         &queue_context
       );
@@ -107,7 +107,6 @@ rtems_status_code rtems_semaphore_obtain(
         &the_semaphore->Core_control.MRSP,
         executing,
         wait,
-        timeout,
         &queue_context
       );
       break;
@@ -122,7 +121,6 @@ rtems_status_code rtems_semaphore_obtain(
         _Semaphore_Get_operations( the_semaphore ),
         executing,
         wait,
-        timeout,
         &queue_context
       );
       break;
diff --git a/cpukit/score/include/rtems/score/corebarrierimpl.h b/cpukit/score/include/rtems/score/corebarrierimpl.h
index d2d9997..a7256b9 100644
--- a/cpukit/score/include/rtems/score/corebarrierimpl.h
+++ b/cpukit/score/include/rtems/score/corebarrierimpl.h
@@ -87,10 +87,6 @@ RTEMS_INLINE_ROUTINE void _CORE_barrier_Release(
  *  @param[in] the_barrier is the barrier to wait for
  *  @param[in,out] executing The currently executing thread.
  *  @param[in] wait is true if the calling thread is willing to wait
- *  @param[in] timeout is the number of ticks the calling thread is willing
- *         to wait if @a wait is true.
- *  @param[in] mp_callout is the routine to invoke if the
- *         thread unblocked is remote
  *
  * @return The method status.
  */
@@ -98,7 +94,6 @@ Status_Control _CORE_barrier_Seize(
   CORE_barrier_Control *the_barrier,
   Thread_Control       *executing,
   bool                  wait,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 );
 
diff --git a/cpukit/score/include/rtems/score/coremsgimpl.h b/cpukit/score/include/rtems/score/coremsgimpl.h
index d240c4a..3b811c9 100644
--- a/cpukit/score/include/rtems/score/coremsgimpl.h
+++ b/cpukit/score/include/rtems/score/coremsgimpl.h
@@ -194,8 +194,6 @@ Status_Control _CORE_message_queue_Broadcast(
  *         appended, or enqueued in priority order.
  *  @param[in] wait indicates whether the calling thread is willing to block
  *         if the message queue is full.
- *  @param[in] timeout is the maximum number of clock ticks that the calling
- *         thread is willing to block if the message queue is full.
  *  @param[in] queue_context The thread queue context used for
  *    _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical().
  *  @retval indication of the successful completion or reason for failure
@@ -207,7 +205,6 @@ Status_Control _CORE_message_queue_Submit(
   size_t                            size,
   CORE_message_queue_Submit_types   submit_type,
   bool                              wait,
-  Watchdog_Interval                 timeout,
   Thread_queue_Context             *queue_context
 );
 
@@ -230,8 +227,6 @@ Status_Control _CORE_message_queue_Submit(
  *         indicates the maximum size message that the caller can receive.
  *  @param[in] wait indicates whether the calling thread is willing to block
  *         if the message queue is empty.
- *  @param[in] timeout is the maximum number of clock ticks that the calling
- *         thread is willing to block if the message queue is empty.
  *  @param[in] queue_context The thread queue context used for
  *    _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical().
  *
@@ -251,7 +246,6 @@ Status_Control _CORE_message_queue_Seize(
   void                       *buffer,
   size_t                     *size_p,
   bool                        wait,
-  Watchdog_Interval           timeout,
   Thread_queue_Context       *queue_context
 );
 
@@ -281,7 +275,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send(
   const void                       *buffer,
   size_t                            size,
   bool                              wait,
-  Watchdog_Interval                 timeout,
   Thread_queue_Context             *queue_context
 )
 {
@@ -292,7 +285,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send(
     size,
     CORE_MESSAGE_QUEUE_SEND_REQUEST,
     wait,
-    timeout,
     queue_context
   );
 }
@@ -302,7 +294,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent(
   const void                       *buffer,
   size_t                            size,
   bool                              wait,
-  Watchdog_Interval                 timeout,
   Thread_queue_Context             *queue_context
 )
 {
@@ -313,7 +304,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent(
     size,
     CORE_MESSAGE_QUEUE_URGENT_REQUEST,
     wait,
-    timeout,
     queue_context
   );
 }
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index 956dfa8..838b52a 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -99,7 +99,6 @@ Status_Control _CORE_mutex_Seize_slow(
   Thread_Control       *executing,
   Thread_Control       *owner,
   bool                  wait,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 );
 
@@ -108,7 +107,6 @@ Status_Control _CORE_mutex_Seize_no_protocol_slow(
   const Thread_queue_Operations *operations,
   Thread_Control                *executing,
   bool                           wait,
-  Watchdog_Interval              timeout,
   Thread_queue_Context          *queue_context
 );
 
@@ -182,7 +180,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize(
   CORE_recursive_mutex_Control  *the_mutex,
   Thread_Control                *executing,
   bool                           wait,
-  Watchdog_Interval              timeout,
   Status_Control              ( *nested )( CORE_recursive_mutex_Control * ),
   Thread_queue_Context          *queue_context
 )
@@ -213,7 +210,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize(
     executing,
     owner,
     wait,
-    timeout,
     queue_context
   );
 }
@@ -276,7 +272,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_no_protocol(
   const Thread_queue_Operations *operations,
   Thread_Control                *executing,
   bool                           wait,
-  Watchdog_Interval              timeout,
   Status_Control              ( *nested )( CORE_recursive_mutex_Control * ),
   Thread_queue_Context          *queue_context
 )
@@ -306,7 +301,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_no_protocol(
     operations,
     executing,
     wait,
-    timeout,
     queue_context
   );
 }
@@ -402,7 +396,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize(
   CORE_ceiling_mutex_Control    *the_mutex,
   Thread_Control                *executing,
   bool                           wait,
-  Watchdog_Interval              timeout,
   Status_Control              ( *nested )( CORE_recursive_mutex_Control * ),
   Thread_queue_Context          *queue_context
 )
@@ -434,7 +427,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize(
     CORE_MUTEX_TQ_OPERATIONS,
     executing,
     wait,
-    timeout,
     queue_context
   );
 }
diff --git a/cpukit/score/include/rtems/score/corerwlockimpl.h b/cpukit/score/include/rtems/score/corerwlockimpl.h
index e80ab0e..ff881fa 100644
--- a/cpukit/score/include/rtems/score/corerwlockimpl.h
+++ b/cpukit/score/include/rtems/score/corerwlockimpl.h
@@ -95,15 +95,12 @@ RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release(
  *
  *  @param[in] the_rwlock is the RWLock to wait for
  *  @param[in] wait is true if the calling thread is willing to wait
- *  @param[in] timeout is the number of ticks the calling thread is willing
- *         to wait if @a wait is true.
  */
 
 Status_Control _CORE_RWLock_Seize_for_reading(
   CORE_RWLock_Control  *the_rwlock,
   Thread_Control       *executing,
   bool                  wait,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 );
 
@@ -114,14 +111,11 @@ Status_Control _CORE_RWLock_Seize_for_reading(
  *
  *  @param[in] the_rwlock is the RWLock to wait for
  *  @param[in] wait is true if the calling thread is willing to wait
- *  @param[in] timeout is the number of ticks the calling thread is willing
- *         to wait if @a wait is true.
  */
 Status_Control _CORE_RWLock_Seize_for_writing(
   CORE_RWLock_Control  *the_rwlock,
   Thread_Control       *executing,
   bool                  wait,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 );
 
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
index a562534..5a28726 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -165,7 +165,6 @@ RTEMS_INLINE_ROUTINE uint32_t  _CORE_semaphore_Get_count(
  * @param[in] operations The thread queue operations.
  * @param[in] executing The currently executing thread.
  * @param[in] wait is true if the thread is willing to wait
- * @param[in] timeout is the maximum number of ticks to block
  * @param[in] queue_context is a temporary variable used to contain the ISR
  *        disable level cookie
  */
@@ -174,7 +173,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize(
   const Thread_queue_Operations *operations,
   Thread_Control                *executing,
   bool                           wait,
-  Watchdog_Interval              timeout,
   Thread_queue_Context          *queue_context
 )
 {
@@ -198,8 +196,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize(
     operations,
     executing,
     STATES_WAITING_FOR_SEMAPHORE,
-    timeout,
-    WATCHDOG_RELATIVE,
     queue_context
   );
   return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index 2ae8f04..a4de767 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -224,7 +224,6 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership(
   Thread_Control       *executing,
   Priority_Control      initial_priority,
   Priority_Control      ceiling_priority,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 )
 {
@@ -234,6 +233,8 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership(
   Per_CPU_Control *cpu_self;
   ISR_lock_Context giant_lock_context;
   ISR_Level level;
+  Watchdog_Interval timeout = queue_context->timeout;
+  Watchdog_Clock clock = queue_context->clock;
 
   rival.thread = executing;
   rival.resource = mrsp;
@@ -267,7 +268,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership(
     _Watchdog_Per_CPU_insert(
       &rival.Watchdog,
       cpu_self,
-      WATCHDOG_RELATIVE,
+      clock,
       timeout
     );
     _ISR_Local_enable( level );
@@ -306,7 +307,6 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize(
   MRSP_Control         *mrsp,
   Thread_Control       *executing,
   bool                  wait,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 )
 {
@@ -348,7 +348,6 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize(
       executing,
       initial_priority,
       ceiling_priority,
-      timeout,
       queue_context
     );
   } else {
diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h
index a4e5292..56f5401 100644
--- a/cpukit/score/include/rtems/score/threadq.h
+++ b/cpukit/score/include/rtems/score/threadq.h
@@ -24,6 +24,7 @@
 #include <rtems/score/object.h>
 #include <rtems/score/priority.h>
 #include <rtems/score/rbtree.h>
+#include <rtems/score/watchdog.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -79,6 +80,16 @@ typedef struct {
   uint32_t expected_thread_dispatch_disable_level;
 
   /**
+   * @brief Interval to wait. Use WATCHDOG_NO_TIMEOUT to block indefinitely.
+   */
+  Watchdog_Interval timeout;
+
+  /**
+   * @brief The kind of clock used for the interval timeout.
+   */
+  Watchdog_Clock clock;
+
+  /**
    * @brief Callout to unblock the thread in case it is actually a thread
    * proxy.
    *
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index f59a334..888e687 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -91,6 +91,40 @@ _Thread_queue_Context_set_expected_level(
 }
 
 /**
+ * @brief Sets the timeout interval in the thread queue context.
+ *
+ * @param queue_context The thread queue context.
+ * @param timeout The new timeout.
+ *
+ * @see _Thread_queue_Enqueue_critical().
+ */
+RTEMS_INLINE_ROUTINE void
+_Thread_queue_Context_set_timeout(
+  Thread_queue_Context *queue_context,
+  Watchdog_Interval     timeout
+)
+{
+  queue_context->timeout = timeout;
+}
+
+/**
+ * @brief Sets the clock type for the timeout in the thread queue context.
+ *
+ * @param queue_context The thread queue context.
+ * @param clock The kind of clock.
+ *
+ * @see _Thread_queue_Enqueue_critical().
+ */
+RTEMS_INLINE_ROUTINE void
+_Thread_queue_Context_set_clock(
+  Thread_queue_Context *queue_context,
+  Watchdog_Clock        clock
+)
+{
+  queue_context->clock = clock;
+}
+
+/**
  * @brief Sets the MP callout in the thread queue context.
  *
  * @param queue_context The thread queue context.
@@ -361,9 +395,6 @@ Thread_Control *_Thread_queue_Do_dequeue(
  * @param[in] operations The thread queue operations.
  * @param[in] the_thread The thread to enqueue.
  * @param[in] state The new state of the thread.
- * @param[in] timeout Interval to wait.  Use WATCHDOG_NO_TIMEOUT to block
- * potentially forever.
- * @param[in] clock The kind of clock used for the interval.
  * @param[in] queue_context The thread queue context of the lock acquire.
  */
 void _Thread_queue_Enqueue_critical(
@@ -371,8 +402,6 @@ void _Thread_queue_Enqueue_critical(
   const Thread_queue_Operations *operations,
   Thread_Control                *the_thread,
   States_Control                 state,
-  Watchdog_Interval              timeout,
-  Watchdog_Clock                 clock,
   Thread_queue_Context          *queue_context
 );
 
@@ -395,13 +424,13 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
   _Thread_queue_Context_initialize( &queue_context );
   _Thread_queue_Acquire( the_thread_queue, &queue_context.Lock_context );
   _Thread_queue_Context_set_expected_level( &queue_context, expected_level );
+  _Thread_queue_Context_set_timeout( &queue_context, timeout );
+  _Thread_queue_Context_set_clock( &queue_context, clock );
   _Thread_queue_Enqueue_critical(
     &the_thread_queue->Queue,
     operations,
     the_thread,
     state,
-    timeout,
-    clock,
     &queue_context
   );
 }
diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c
index df53e75..68893cf 100644
--- a/cpukit/score/src/apimutexlock.c
+++ b/cpukit/score/src/apimutexlock.c
@@ -33,12 +33,12 @@ void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
 
   _Thread_queue_Context_initialize( &queue_context );
   _ISR_lock_ISR_disable( &queue_context.Lock_context );
-
+  _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   _CORE_recursive_mutex_Seize(
     &the_mutex->Mutex,
     _Thread_Executing,
     true,
-    WATCHDOG_NO_TIMEOUT,
     _CORE_recursive_mutex_Seize_nested,
     &queue_context
   );
diff --git a/cpukit/score/src/condition.c b/cpukit/score/src/condition.c
index 80f1ad7..6ae2f17 100644
--- a/cpukit/score/src/condition.c
+++ b/cpukit/score/src/condition.c
@@ -82,7 +82,6 @@ static void _Condition_Queue_release(
 
 static Per_CPU_Control *_Condition_Do_wait(
   struct _Condition_Control *_condition,
-  Watchdog_Interval          timeout,
   Thread_queue_Context      *queue_context
 )
 {
@@ -100,8 +99,6 @@ static Per_CPU_Control *_Condition_Do_wait(
     CONDITION_TQ_OPERATIONS,
     executing,
     STATES_WAITING_FOR_SYS_LOCK_CONDITION,
-    timeout,
-    WATCHDOG_RELATIVE,
     queue_context
   );
 
@@ -118,7 +115,12 @@ void _Condition_Wait(
 
   _Thread_queue_Context_initialize( &queue_context );
   _ISR_lock_ISR_disable( &queue_context.Lock_context );
-  cpu_self = _Condition_Do_wait( _condition, 0, &queue_context );
+  _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
+  cpu_self = _Condition_Do_wait(
+    _condition,
+    &queue_context
+  );
 
   _Mutex_Release( _mutex );
   _Thread_Dispatch_enable( cpu_self );
@@ -152,7 +154,9 @@ int _Condition_Wait_timed(
       break;
   }
 
-  cpu_self = _Condition_Do_wait( _condition, ticks, &queue_context );
+  _Thread_queue_Context_set_timeout( &queue_context, ticks );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
+  cpu_self = _Condition_Do_wait( _condition, &queue_context );
 
   _Mutex_Release( _mutex );
   executing = cpu_self->executing;
@@ -174,7 +178,9 @@ void _Condition_Wait_recursive(
 
   _Thread_queue_Context_initialize( &queue_context );
   _ISR_lock_ISR_disable( &queue_context.Lock_context );
-  cpu_self = _Condition_Do_wait( _condition, 0, &queue_context );
+  _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
+  cpu_self = _Condition_Do_wait( _condition, &queue_context );
 
   nest_level = _mutex->_nest_level;
   _mutex->_nest_level = 0;
@@ -212,7 +218,9 @@ int _Condition_Wait_recursive_timed(
       break;
   }
 
-  cpu_self = _Condition_Do_wait( _condition, ticks, &queue_context );
+  _Thread_queue_Context_set_timeout( &queue_context, ticks );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
+  cpu_self = _Condition_Do_wait( _condition, &queue_context );
 
   nest_level = _mutex->_nest_level;
   _mutex->_nest_level = 0;
diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c
index 3874221..7e46c93 100644
--- a/cpukit/score/src/corebarrierwait.c
+++ b/cpukit/score/src/corebarrierwait.c
@@ -26,7 +26,6 @@ Status_Control _CORE_barrier_Seize(
   CORE_barrier_Control *the_barrier,
   Thread_Control       *executing,
   bool                  wait,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 )
 {
@@ -51,8 +50,6 @@ Status_Control _CORE_barrier_Seize(
       CORE_BARRIER_TQ_OPERATIONS,
       executing,
       STATES_WAITING_FOR_BARRIER,
-      timeout,
-      WATCHDOG_RELATIVE,
       queue_context
     );
     return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c
index 7e6b4ee..d86afd0 100644
--- a/cpukit/score/src/coremsgseize.c
+++ b/cpukit/score/src/coremsgseize.c
@@ -31,7 +31,6 @@ Status_Control _CORE_message_queue_Seize(
   void                       *buffer,
   size_t                     *size_p,
   bool                        wait,
-  Watchdog_Interval           timeout,
   Thread_queue_Context       *queue_context
 )
 {
@@ -120,8 +119,6 @@ Status_Control _CORE_message_queue_Seize(
     the_message_queue->operations,
     executing,
     STATES_WAITING_FOR_MESSAGE,
-    timeout,
-    WATCHDOG_RELATIVE,
     queue_context
   );
   return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c
index d355755..97b4382 100644
--- a/cpukit/score/src/coremsgsubmit.c
+++ b/cpukit/score/src/coremsgsubmit.c
@@ -33,7 +33,6 @@ Status_Control _CORE_message_queue_Submit(
   size_t                            size,
   CORE_message_queue_Submit_types   submit_type,
   bool                              wait,
-  Watchdog_Interval                 timeout,
   Thread_queue_Context             *queue_context
 )
 {
@@ -138,8 +137,6 @@ Status_Control _CORE_message_queue_Submit(
       the_message_queue->operations,
       executing,
       STATES_WAITING_FOR_MESSAGE,
-      timeout,
-      WATCHDOG_RELATIVE,
       queue_context
     );
     return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index 5d1f72f..c468c07 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -28,7 +28,6 @@ Status_Control _CORE_mutex_Seize_slow(
   Thread_Control       *executing,
   Thread_Control       *owner,
   bool                  wait,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 )
 {
@@ -70,8 +69,6 @@ Status_Control _CORE_mutex_Seize_slow(
     CORE_MUTEX_TQ_OPERATIONS,
     executing,
     STATES_WAITING_FOR_MUTEX,
-    timeout,
-    WATCHDOG_RELATIVE,
     queue_context
   );
 
@@ -87,7 +84,6 @@ Status_Control _CORE_mutex_Seize_no_protocol_slow(
   const Thread_queue_Operations *operations,
   Thread_Control                *executing,
   bool                           wait,
-  Watchdog_Interval              timeout,
   Thread_queue_Context          *queue_context
 )
 {
@@ -98,8 +94,6 @@ Status_Control _CORE_mutex_Seize_no_protocol_slow(
       operations,
       executing,
       STATES_WAITING_FOR_MUTEX,
-      timeout,
-      WATCHDOG_RELATIVE,
       queue_context
     );
     return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c
index 43089d0..09b26af 100644
--- a/cpukit/score/src/corerwlockobtainread.c
+++ b/cpukit/score/src/corerwlockobtainread.c
@@ -28,7 +28,6 @@ Status_Control _CORE_RWLock_Seize_for_reading(
   CORE_RWLock_Control  *the_rwlock,
   Thread_Control       *executing,
   bool                  wait,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 )
 {
@@ -85,8 +84,6 @@ Status_Control _CORE_RWLock_Seize_for_reading(
      CORE_RWLOCK_TQ_OPERATIONS,
      executing,
      STATES_WAITING_FOR_RWLOCK,
-     timeout,
-     WATCHDOG_RELATIVE,
      queue_context
   );
   return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c
index 7d9815a..9aac5e7 100644
--- a/cpukit/score/src/corerwlockobtainwrite.c
+++ b/cpukit/score/src/corerwlockobtainwrite.c
@@ -28,7 +28,6 @@ Status_Control _CORE_RWLock_Seize_for_writing(
   CORE_RWLock_Control  *the_rwlock,
   Thread_Control       *executing,
   bool                  wait,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 )
 {
@@ -73,8 +72,6 @@ Status_Control _CORE_RWLock_Seize_for_writing(
      CORE_RWLOCK_TQ_OPERATIONS,
      executing,
      STATES_WAITING_FOR_RWLOCK,
-     timeout,
-     WATCHDOG_RELATIVE,
      queue_context
   );
   return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/futex.c b/cpukit/score/src/futex.c
index f585f99..f17bec2 100644
--- a/cpukit/score/src/futex.c
+++ b/cpukit/score/src/futex.c
@@ -89,13 +89,13 @@ int _Futex_Wait( struct _Futex_Control *_futex, int *uaddr, int val )
 
   if ( *uaddr == val ) {
     _Thread_queue_Context_set_expected_level( &queue_context, 1 );
+    _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+    _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
     _Thread_queue_Enqueue_critical(
       &futex->Queue.Queue,
       FUTEX_TQ_OPERATIONS,
       executing,
       STATES_WAITING_FOR_SYS_LOCK_FUTEX,
-      WATCHDOG_NO_TIMEOUT,
-      WATCHDOG_RELATIVE,
       &queue_context
     );
     eno = 0;
diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c
index e7b631e..eb5611c 100644
--- a/cpukit/score/src/mutex.c
+++ b/cpukit/score/src/mutex.c
@@ -104,7 +104,6 @@ static void _Mutex_Acquire_slow(
   Mutex_Control        *mutex,
   Thread_Control       *owner,
   Thread_Control       *executing,
-  Watchdog_Interval     timeout,
   Thread_queue_Context *queue_context
 )
 {
@@ -115,8 +114,6 @@ static void _Mutex_Acquire_slow(
     MUTEX_TQ_OPERATIONS,
     executing,
     STATES_WAITING_FOR_SYS_LOCK_MUTEX,
-    timeout,
-    WATCHDOG_RELATIVE,
     queue_context
   );
 }
@@ -220,7 +217,9 @@ void _Mutex_Acquire( struct _Mutex_Control *_mutex )
     ++executing->resource_count;
     _Mutex_Queue_release( mutex, &queue_context );
   } else {
-    _Mutex_Acquire_slow( mutex, owner, executing, 0, &queue_context );
+    _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+    _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
+    _Mutex_Acquire_slow( mutex, owner, executing, &queue_context );
   }
 }
 
@@ -261,7 +260,9 @@ int _Mutex_Acquire_timed(
         break;
     }
 
-    _Mutex_Acquire_slow( mutex, owner, executing, ticks, &queue_context );
+    _Thread_queue_Context_set_timeout( &queue_context, ticks );
+    _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
+    _Mutex_Acquire_slow( mutex, owner, executing, &queue_context );
 
     return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
   }
@@ -337,7 +338,9 @@ void _Mutex_recursive_Acquire( struct _Mutex_recursive_Control *_mutex )
     ++mutex->nest_level;
     _Mutex_Queue_release( &mutex->Mutex, &queue_context );
   } else {
-    _Mutex_Acquire_slow( &mutex->Mutex, owner, executing, 0, &queue_context );
+    _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+    _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
+    _Mutex_Acquire_slow( &mutex->Mutex, owner, executing, &queue_context );
   }
 }
 
@@ -383,13 +386,9 @@ int _Mutex_recursive_Acquire_timed(
         break;
     }
 
-    _Mutex_Acquire_slow(
-      &mutex->Mutex,
-      owner,
-      executing,
-      ticks,
-      &queue_context
-    );
+    _Thread_queue_Context_set_timeout( &queue_context, ticks );
+    _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
+    _Mutex_Acquire_slow( &mutex->Mutex, owner, executing, &queue_context );
 
     return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
   }
diff --git a/cpukit/score/src/semaphore.c b/cpukit/score/src/semaphore.c
index 84907e2..2be2759 100644
--- a/cpukit/score/src/semaphore.c
+++ b/cpukit/score/src/semaphore.c
@@ -101,13 +101,13 @@ void _Semaphore_Wait( struct _Semaphore_Control *_sem )
     _Semaphore_Queue_release( sem, &queue_context );
   } else {
     _Thread_queue_Context_set_expected_level( &queue_context, 1 );
+    _Thread_queue_Context_set_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+    _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
     _Thread_queue_Enqueue_critical(
       &sem->Queue.Queue,
       SEMAPHORE_TQ_OPERATIONS,
       executing,
       STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE,
-      WATCHDOG_NO_TIMEOUT,
-      WATCHDOG_RELATIVE,
       &queue_context
     );
   }
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 6a14fec..0115f18 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -39,13 +39,13 @@ void _Thread_queue_Enqueue_critical(
   const Thread_queue_Operations *operations,
   Thread_Control                *the_thread,
   States_Control                 state,
-  Watchdog_Interval              timeout,
-  Watchdog_Clock                 clock,
   Thread_queue_Context          *queue_context
 )
 {
   Per_CPU_Control *cpu_self;
   bool             success;
+  Watchdog_Interval timeout = queue_context->timeout;
+  Watchdog_Clock clock = queue_context->clock;
 
 #if defined(RTEMS_MULTIPROCESSING)
   if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet ) {
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 1bb18aa..54c3c7b 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -461,8 +461,6 @@ void _Thread_Join(
     THREAD_JOIN_TQ_OPERATIONS,
     executing,
     waiting_for_join,
-    WATCHDOG_NO_TIMEOUT,
-    WATCHDOG_RELATIVE,
     queue_context
   );
 }
@@ -529,6 +527,8 @@ 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_timeout( &queue_context, WATCHDOG_NO_TIMEOUT );
+  _Thread_queue_Context_set_clock( &queue_context, WATCHDOG_RELATIVE );
   _Thread_State_acquire( the_thread, &queue_context.Lock_context );
   _Thread_Join(
     the_thread,
-- 
1.9.1

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to