cpukit: Add and use Watchdog_Discipline.

Clock disciplines may be WATCHDOG_RELATIVE, WATCHDOG_ABSOLUTE,
or WATCHDOG_NO_TIMEOUT. A discipline of WATCHDOG_RELATIVE with
a timeout of WATCHDOG_NO_TIMEOUT is equivalent to a discipline
of WATCHDOG_NO_TIMEOUT.

updates #2732
This commit is contained in:
Gedare Bloom
2016-06-09 11:33:15 -04:00
parent 7f616dddcf
commit f23d470616
47 changed files with 200 additions and 144 deletions

View File

@@ -376,11 +376,11 @@ rtems_bsdnet_semaphore_obtain (void)
rtems_panic ("rtems-net: network sema obtain: network not initialised\n"); rtems_panic ("rtems-net: network sema obtain: network not initialised\n");
_Thread_queue_Context_initialize(&queue_context); _Thread_queue_Context_initialize(&queue_context);
_ISR_lock_ISR_disable(&queue_context.Lock_context); _ISR_lock_ISR_disable(&queue_context.Lock_context);
_Thread_queue_Context_set_no_timeout( &queue_context );
status = _CORE_recursive_mutex_Seize ( status = _CORE_recursive_mutex_Seize (
&the_networkSemaphore->Core_control.Mutex.Recursive, &the_networkSemaphore->Core_control.Mutex.Recursive,
_Thread_Executing, _Thread_Executing,
true, /* wait */ true, /* wait */
WATCHDOG_NO_TIMEOUT, /* forever */
_CORE_recursive_mutex_Seize_nested, _CORE_recursive_mutex_Seize_nested,
&queue_context &queue_context
); );

View File

@@ -68,12 +68,13 @@ int _POSIX_Condition_variables_Wait_support(
if ( !already_timedout ) { if ( !already_timedout ) {
_Thread_queue_Context_set_expected_level( &queue_context, 2 ); _Thread_queue_Context_set_expected_level( &queue_context, 2 );
_Thread_queue_Context_set_timeout( &queue_context, timeout );
_Thread_queue_Context_set_discipline( &queue_context, WATCHDOG_RELATIVE );
_Thread_queue_Enqueue_critical( _Thread_queue_Enqueue_critical(
&the_cond->Wait_queue.Queue, &the_cond->Wait_queue.Queue,
POSIX_CONDITION_VARIABLES_TQ_OPERATIONS, POSIX_CONDITION_VARIABLES_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_CONDITION_VARIABLE, STATES_WAITING_FOR_CONDITION_VARIABLE,
timeout,
&queue_context &queue_context
); );
} else { } else {

View File

@@ -97,13 +97,13 @@ ssize_t _POSIX_Message_queue_Receive_support(
* Now perform the actual message receive * Now perform the actual message receive
*/ */
executing = _Thread_Executing; executing = _Thread_Executing;
_Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
status = _CORE_message_queue_Seize( status = _CORE_message_queue_Seize(
&the_mq->Message_queue, &the_mq->Message_queue,
executing, executing,
msg_ptr, msg_ptr,
&length_out, &length_out,
do_wait, do_wait,
timeout,
&queue_context &queue_context
); );

View File

@@ -92,6 +92,7 @@ int _POSIX_Message_queue_Send_support(
* Now perform the actual message receive * Now perform the actual message receive
*/ */
executing = _Thread_Executing; executing = _Thread_Executing;
_Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
status = _CORE_message_queue_Submit( status = _CORE_message_queue_Submit(
&the_mq->Message_queue, &the_mq->Message_queue,
executing, executing,
@@ -99,7 +100,6 @@ int _POSIX_Message_queue_Send_support(
msg_len, msg_len,
_POSIX_Message_queue_Priority_to_core( msg_prio ), _POSIX_Message_queue_Priority_to_core( msg_prio ),
do_wait, do_wait,
timeout,
&queue_context &queue_context
); );
return _POSIX_Zero_or_minus_one_plus_errno( status ); return _POSIX_Zero_or_minus_one_plus_errno( status );

View File

@@ -63,6 +63,7 @@ int _POSIX_Mutex_Lock_support(
} }
executing = _Thread_Executing; executing = _Thread_Executing;
_Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
switch ( the_mutex->protocol ) { switch ( the_mutex->protocol ) {
case POSIX_MUTEX_PRIORITY_CEILING: case POSIX_MUTEX_PRIORITY_CEILING:
@@ -70,7 +71,6 @@ int _POSIX_Mutex_Lock_support(
&the_mutex->Mutex, &the_mutex->Mutex,
executing, executing,
wait, wait,
timeout,
_POSIX_Mutex_Lock_nested, _POSIX_Mutex_Lock_nested,
&queue_context &queue_context
); );
@@ -81,7 +81,6 @@ int _POSIX_Mutex_Lock_support(
POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS, POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
executing, executing,
wait, wait,
timeout,
_POSIX_Mutex_Lock_nested, _POSIX_Mutex_Lock_nested,
&queue_context &queue_context
); );
@@ -92,7 +91,6 @@ int _POSIX_Mutex_Lock_support(
&the_mutex->Mutex.Recursive, &the_mutex->Mutex.Recursive,
executing, executing,
wait, wait,
timeout,
_POSIX_Mutex_Lock_nested, _POSIX_Mutex_Lock_nested,
&queue_context &queue_context
); );

View File

@@ -93,6 +93,7 @@ int nanosleep(
executing, executing,
STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL, STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL,
ticks, ticks,
WATCHDOG_RELATIVE,
1 1
); );

View File

@@ -41,11 +41,11 @@ int pthread_barrier_wait(
return EINVAL; return EINVAL;
} }
_Thread_queue_Context_set_no_timeout( &queue_context );
status = _CORE_barrier_Seize( status = _CORE_barrier_Seize(
&the_barrier->Barrier, &the_barrier->Barrier,
_Thread_Executing, _Thread_Executing,
true, true,
WATCHDOG_NO_TIMEOUT,
&queue_context &queue_context
); );
return _POSIX_Get_error( status ); return _POSIX_Get_error( status );

View File

@@ -35,11 +35,11 @@ int pthread_rwlock_rdlock(
return EINVAL; return EINVAL;
} }
_Thread_queue_Context_set_no_timeout( &queue_context );
status = _CORE_RWLock_Seize_for_reading( status = _CORE_RWLock_Seize_for_reading(
&the_rwlock->RWLock, &the_rwlock->RWLock,
_Thread_Executing, _Thread_Executing,
true, /* we are willing to wait forever */ true, /* we are willing to wait forever */
0,
&queue_context &queue_context
); );
return _POSIX_Get_error( status ); return _POSIX_Get_error( status );

View File

@@ -56,11 +56,11 @@ int pthread_rwlock_timedrdlock(
return EINVAL; return EINVAL;
} }
_Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
status = _CORE_RWLock_Seize_for_reading( status = _CORE_RWLock_Seize_for_reading(
&the_rwlock->RWLock, &the_rwlock->RWLock,
_Thread_Executing, _Thread_Executing,
do_wait, do_wait,
ticks,
&queue_context &queue_context
); );

View File

@@ -58,11 +58,11 @@ int pthread_rwlock_timedwrlock(
return EINVAL; return EINVAL;
} }
_Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
status = _CORE_RWLock_Seize_for_writing( status = _CORE_RWLock_Seize_for_writing(
&the_rwlock->RWLock, &the_rwlock->RWLock,
_Thread_Executing, _Thread_Executing,
do_wait, do_wait,
ticks,
&queue_context &queue_context
); );

View File

@@ -39,7 +39,6 @@ int pthread_rwlock_tryrdlock(
&the_rwlock->RWLock, &the_rwlock->RWLock,
_Thread_Executing, _Thread_Executing,
false, /* do not wait for the rwlock */ false, /* do not wait for the rwlock */
0,
&queue_context &queue_context
); );
return _POSIX_Get_error( status ); return _POSIX_Get_error( status );

View File

@@ -39,7 +39,6 @@ int pthread_rwlock_trywrlock(
&the_rwlock->RWLock, &the_rwlock->RWLock,
_Thread_Executing, _Thread_Executing,
false, /* we are not willing to wait */ false, /* we are not willing to wait */
0,
&queue_context &queue_context
); );
return _POSIX_Get_error( status ); return _POSIX_Get_error( status );

View File

@@ -39,11 +39,11 @@ int pthread_rwlock_wrlock(
return EINVAL; return EINVAL;
} }
_Thread_queue_Context_set_no_timeout( &queue_context );
status = _CORE_RWLock_Seize_for_writing( status = _CORE_RWLock_Seize_for_writing(
&the_rwlock->RWLock, &the_rwlock->RWLock,
_Thread_Executing, _Thread_Executing,
true, /* do not timeout -- wait forever */ true, /* do not timeout -- wait forever */
0,
&queue_context &queue_context
); );
return _POSIX_Get_error( status ); return _POSIX_Get_error( status );

View File

@@ -40,6 +40,7 @@ static int _POSIX_Threads_Join( pthread_t thread, void **value_ptr )
_Thread_queue_Context_initialize( &queue_context ); _Thread_queue_Context_initialize( &queue_context );
_Thread_queue_Context_set_expected_level( &queue_context, 1 ); _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 );
if ( the_thread == NULL ) { if ( the_thread == NULL ) {

View File

@@ -41,12 +41,12 @@ int _POSIX_Semaphore_Wait_support(
rtems_set_errno_and_return_minus_one( EINVAL ); rtems_set_errno_and_return_minus_one( EINVAL );
} }
_Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
status = _CORE_semaphore_Seize( status = _CORE_semaphore_Seize(
&the_semaphore->Semaphore, &the_semaphore->Semaphore,
POSIX_SEMAPHORE_TQ_OPERATIONS, POSIX_SEMAPHORE_TQ_OPERATIONS,
_Thread_Executing, _Thread_Executing,
blocking, blocking,
timeout,
&queue_context &queue_context
); );
return _POSIX_Zero_or_minus_one_plus_errno( status ); return _POSIX_Zero_or_minus_one_plus_errno( status );

View File

@@ -153,12 +153,12 @@ int sigtimedwait(
executing->Wait.option = *set; executing->Wait.option = *set;
executing->Wait.return_argument = the_info; executing->Wait.return_argument = the_info;
_Thread_queue_Context_set_expected_level( &queue_context, 1 ); _Thread_queue_Context_set_expected_level( &queue_context, 1 );
_Thread_queue_Context_set_relative_timeout( &queue_context, interval );
_Thread_queue_Enqueue_critical( _Thread_queue_Enqueue_critical(
&_POSIX_signals_Wait_queue.Queue, &_POSIX_signals_Wait_queue.Queue,
POSIX_SIGNALS_TQ_OPERATIONS, POSIX_SIGNALS_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL, STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL,
interval,
&queue_context &queue_context
); );

View File

@@ -38,11 +38,11 @@ rtems_status_code rtems_barrier_wait(
return RTEMS_INVALID_ID; return RTEMS_INVALID_ID;
} }
_Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
status = _CORE_barrier_Seize( status = _CORE_barrier_Seize(
&the_barrier->Barrier, &the_barrier->Barrier,
_Thread_Executing, _Thread_Executing,
true, true,
timeout,
&queue_context &queue_context
); );
return _Status_Get( status ); return _Status_Get( status );

View File

@@ -61,13 +61,13 @@ rtems_status_code rtems_message_queue_receive(
); );
executing = _Thread_Executing; executing = _Thread_Executing;
_Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
status = _CORE_message_queue_Seize( status = _CORE_message_queue_Seize(
&the_message_queue->message_queue, &the_message_queue->message_queue,
executing, executing,
buffer, buffer,
size, size,
!_Options_Is_no_wait( option_set ), !_Options_Is_no_wait( option_set ),
timeout,
&queue_context &queue_context
); );
return _Status_Get( status ); return _Status_Get( status );

View File

@@ -58,7 +58,6 @@ rtems_status_code rtems_message_queue_send(
buffer, buffer,
size, size,
false, /* sender does not block */ false, /* sender does not block */
0, /* no timeout */
&queue_context &queue_context
); );
return _Status_Get( status ); return _Status_Get( status );

View File

@@ -58,7 +58,6 @@ rtems_status_code rtems_message_queue_urgent(
buffer, buffer,
size, size,
false, /* sender does not block */ false, /* sender does not block */
0, /* no timeout */
&queue_context &queue_context
); );
return _Status_Get( status ); return _Status_Get( status );

View File

@@ -87,6 +87,7 @@ rtems_status_code rtems_region_get_segment(
executing, executing,
STATES_WAITING_FOR_SEGMENT, STATES_WAITING_FOR_SEGMENT,
timeout, timeout,
WATCHDOG_RELATIVE,
2 2
); );

View File

@@ -69,13 +69,14 @@ rtems_status_code rtems_semaphore_obtain(
executing = _Thread_Executing; executing = _Thread_Executing;
wait = !_Options_Is_no_wait( option_set ); wait = !_Options_Is_no_wait( option_set );
_Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
switch ( the_semaphore->variant ) { switch ( the_semaphore->variant ) {
case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY: case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
status = _CORE_recursive_mutex_Seize( status = _CORE_recursive_mutex_Seize(
&the_semaphore->Core_control.Mutex.Recursive, &the_semaphore->Core_control.Mutex.Recursive,
executing, executing,
wait, wait,
timeout,
_CORE_recursive_mutex_Seize_nested, _CORE_recursive_mutex_Seize_nested,
&queue_context &queue_context
); );
@@ -85,7 +86,6 @@ rtems_status_code rtems_semaphore_obtain(
&the_semaphore->Core_control.Mutex, &the_semaphore->Core_control.Mutex,
executing, executing,
wait, wait,
timeout,
_CORE_recursive_mutex_Seize_nested, _CORE_recursive_mutex_Seize_nested,
&queue_context &queue_context
); );
@@ -96,7 +96,6 @@ rtems_status_code rtems_semaphore_obtain(
_Semaphore_Get_operations( the_semaphore ), _Semaphore_Get_operations( the_semaphore ),
executing, executing,
wait, wait,
timeout,
_CORE_recursive_mutex_Seize_nested, _CORE_recursive_mutex_Seize_nested,
&queue_context &queue_context
); );
@@ -107,7 +106,6 @@ rtems_status_code rtems_semaphore_obtain(
&the_semaphore->Core_control.MRSP, &the_semaphore->Core_control.MRSP,
executing, executing,
wait, wait,
timeout,
&queue_context &queue_context
); );
break; break;
@@ -122,7 +120,6 @@ rtems_status_code rtems_semaphore_obtain(
_Semaphore_Get_operations( the_semaphore ), _Semaphore_Get_operations( the_semaphore ),
executing, executing,
wait, wait,
timeout,
&queue_context &queue_context
); );
break; break;

View File

@@ -87,10 +87,6 @@ RTEMS_INLINE_ROUTINE void _CORE_barrier_Release(
* @param[in] the_barrier is the barrier to wait for * @param[in] the_barrier is the barrier to wait for
* @param[in,out] executing The currently executing thread. * @param[in,out] executing The currently executing thread.
* @param[in] wait is true if the calling thread is willing to wait * @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. * @return The method status.
*/ */
@@ -98,7 +94,6 @@ Status_Control _CORE_barrier_Seize(
CORE_barrier_Control *the_barrier, CORE_barrier_Control *the_barrier,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
); );

View File

@@ -194,8 +194,6 @@ Status_Control _CORE_message_queue_Broadcast(
* appended, or enqueued in priority order. * appended, or enqueued in priority order.
* @param[in] wait indicates whether the calling thread is willing to block * @param[in] wait indicates whether the calling thread is willing to block
* if the message queue is full. * 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 * @param[in] queue_context The thread queue context used for
* _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical().
* @retval indication of the successful completion or reason for failure * @retval indication of the successful completion or reason for failure
@@ -207,7 +205,6 @@ Status_Control _CORE_message_queue_Submit(
size_t size, size_t size,
CORE_message_queue_Submit_types submit_type, CORE_message_queue_Submit_types submit_type,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context 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. * indicates the maximum size message that the caller can receive.
* @param[in] wait indicates whether the calling thread is willing to block * @param[in] wait indicates whether the calling thread is willing to block
* if the message queue is empty. * 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 * @param[in] queue_context The thread queue context used for
* _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical().
* *
@@ -251,7 +246,6 @@ Status_Control _CORE_message_queue_Seize(
void *buffer, void *buffer,
size_t *size_p, size_t *size_p,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
); );
@@ -281,7 +275,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send(
const void *buffer, const void *buffer,
size_t size, size_t size,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -292,7 +285,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send(
size, size,
CORE_MESSAGE_QUEUE_SEND_REQUEST, CORE_MESSAGE_QUEUE_SEND_REQUEST,
wait, wait,
timeout,
queue_context queue_context
); );
} }
@@ -302,7 +294,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent(
const void *buffer, const void *buffer,
size_t size, size_t size,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -313,7 +304,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent(
size, size,
CORE_MESSAGE_QUEUE_URGENT_REQUEST, CORE_MESSAGE_QUEUE_URGENT_REQUEST,
wait, wait,
timeout,
queue_context queue_context
); );
} }

View File

@@ -100,7 +100,6 @@ Status_Control _CORE_mutex_Seize_slow(
Thread_Control *executing, Thread_Control *executing,
Thread_Control *owner, Thread_Control *owner,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
); );
@@ -109,7 +108,6 @@ Status_Control _CORE_mutex_Seize_no_protocol_slow(
const Thread_queue_Operations *operations, const Thread_queue_Operations *operations,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
); );
@@ -183,7 +181,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize(
CORE_recursive_mutex_Control *the_mutex, CORE_recursive_mutex_Control *the_mutex,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Status_Control ( *nested )( CORE_recursive_mutex_Control * ), Status_Control ( *nested )( CORE_recursive_mutex_Control * ),
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
@@ -214,7 +211,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize(
executing, executing,
owner, owner,
wait, wait,
timeout,
queue_context queue_context
); );
} }
@@ -277,7 +273,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_no_protocol(
const Thread_queue_Operations *operations, const Thread_queue_Operations *operations,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Status_Control ( *nested )( CORE_recursive_mutex_Control * ), Status_Control ( *nested )( CORE_recursive_mutex_Control * ),
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
@@ -307,7 +302,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_no_protocol(
operations, operations,
executing, executing,
wait, wait,
timeout,
queue_context queue_context
); );
} }
@@ -434,7 +428,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize(
CORE_ceiling_mutex_Control *the_mutex, CORE_ceiling_mutex_Control *the_mutex,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Status_Control ( *nested )( CORE_recursive_mutex_Control * ), Status_Control ( *nested )( CORE_recursive_mutex_Control * ),
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
@@ -476,7 +469,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize(
CORE_MUTEX_TQ_OPERATIONS, CORE_MUTEX_TQ_OPERATIONS,
executing, executing,
wait, wait,
timeout,
queue_context queue_context
); );
} }

View File

@@ -95,15 +95,12 @@ RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release(
* *
* @param[in] the_rwlock is the RWLock to wait for * @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] 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( Status_Control _CORE_RWLock_Seize_for_reading(
CORE_RWLock_Control *the_rwlock, CORE_RWLock_Control *the_rwlock,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context 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] the_rwlock is the RWLock to wait for
* @param[in] wait is true if the calling thread is willing to wait * @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( Status_Control _CORE_RWLock_Seize_for_writing(
CORE_RWLock_Control *the_rwlock, CORE_RWLock_Control *the_rwlock,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
); );

View File

@@ -165,7 +165,6 @@ RTEMS_INLINE_ROUTINE uint32_t _CORE_semaphore_Get_count(
* @param[in] operations The thread queue operations. * @param[in] operations The thread queue operations.
* @param[in] executing The currently executing thread. * @param[in] executing The currently executing thread.
* @param[in] wait is true if the thread is willing to wait * @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 * @param[in] queue_context is a temporary variable used to contain the ISR
* disable level cookie * disable level cookie
*/ */
@@ -174,7 +173,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize(
const Thread_queue_Operations *operations, const Thread_queue_Operations *operations,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -198,7 +196,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize(
operations, operations,
executing, executing,
STATES_WAITING_FOR_SEMAPHORE, STATES_WAITING_FOR_SEMAPHORE,
timeout,
queue_context queue_context
); );
return _Thread_Wait_get_status( executing ); return _Thread_Wait_get_status( executing );

View File

@@ -240,7 +240,6 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership(
Thread_Control *executing, Thread_Control *executing,
Priority_Control initial_priority, Priority_Control initial_priority,
Priority_Control ceiling_priority, Priority_Control ceiling_priority,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -250,6 +249,8 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership(
Per_CPU_Control *cpu_self; Per_CPU_Control *cpu_self;
ISR_lock_Context giant_lock_context; ISR_lock_Context giant_lock_context;
ISR_Level level; ISR_Level level;
Watchdog_Interval timeout = queue_context->timeout;
_Assert( queue_context->timeout_discipline == WATCHDOG_RELATIVE );
rival.thread = executing; rival.thread = executing;
rival.resource = mrsp; rival.resource = mrsp;
@@ -317,7 +318,6 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize(
MRSP_Control *mrsp, MRSP_Control *mrsp,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -357,7 +357,6 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize(
executing, executing,
initial_priority, initial_priority,
ceiling_priority, ceiling_priority,
timeout,
queue_context queue_context
); );
} else { } else {

View File

@@ -1511,7 +1511,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_relative(
_ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context ); _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context );
the_thread->Timer.header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ]; the_thread->Timer.header = &cpu->Watchdog.Header[PER_CPU_WATCHDOG_RELATIVE];
the_thread->Timer.Watchdog.routine = routine; the_thread->Timer.Watchdog.routine = routine;
_Watchdog_Per_CPU_insert_relative( &the_thread->Timer.Watchdog, cpu, ticks ); _Watchdog_Per_CPU_insert_relative( &the_thread->Timer.Watchdog, cpu, ticks );
@@ -1522,20 +1522,23 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_absolute(
Thread_Control *the_thread, Thread_Control *the_thread,
Per_CPU_Control *cpu, Per_CPU_Control *cpu,
Watchdog_Service_routine_entry routine, Watchdog_Service_routine_entry routine,
uint64_t expire uint64_t ticks
) )
{ {
ISR_lock_Context lock_context; ISR_lock_Context lock_context;
_ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context ); _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context );
the_thread->Timer.header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ]; the_thread->Timer.header = &cpu->Watchdog.Header[PER_CPU_WATCHDOG_ABSOLUTE];
the_thread->Timer.Watchdog.routine = routine; the_thread->Timer.Watchdog.routine = routine;
_Watchdog_Per_CPU_insert_absolute( &the_thread->Timer.Watchdog, cpu, expire ); _Watchdog_Per_CPU_insert_absolute( &the_thread->Timer.Watchdog, cpu, ticks );
_ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context ); _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context );
} }
RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread ) RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread )
{ {
ISR_lock_Context lock_context; ISR_lock_Context lock_context;

View File

@@ -24,6 +24,7 @@
#include <rtems/score/object.h> #include <rtems/score/object.h>
#include <rtems/score/priority.h> #include <rtems/score/priority.h>
#include <rtems/score/rbtree.h> #include <rtems/score/rbtree.h>
#include <rtems/score/watchdog.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -78,6 +79,17 @@ typedef struct {
*/ */
uint32_t expected_thread_dispatch_disable_level; 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 Callout to unblock the thread in case it is actually a thread * @brief Callout to unblock the thread in case it is actually a thread
* proxy. * proxy.

View File

@@ -90,6 +90,58 @@ _Thread_queue_Context_set_expected_level(
queue_context->expected_thread_dispatch_disable_level = expected_level; queue_context->expected_thread_dispatch_disable_level = expected_level;
} }
/**
* @brief Sets an indefinite 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_no_timeout(
Thread_queue_Context *queue_context
)
{
queue_context->timeout_discipline = WATCHDOG_NO_TIMEOUT;
}
/**
* @brief Sets a relative timeout in the thread queue context.
*
* @param queue_context The thread queue context.
* @param discipline The clock discipline to use for the timeout.
*
* @see _Thread_queue_Enqueue_critical().
*/
RTEMS_INLINE_ROUTINE void
_Thread_queue_Context_set_relative_timeout(
Thread_queue_Context *queue_context,
Watchdog_Interval timeout
)
{
queue_context->timeout_discipline = WATCHDOG_RELATIVE;
queue_context->timeout = timeout;
}
/**
* @brief Sets an absolute timeout in the thread queue context.
*
* @param queue_context The thread queue context.
* @param discipline The clock discipline to use for the timeout.
*
* @see _Thread_queue_Enqueue_critical().
*/
RTEMS_INLINE_ROUTINE void
_Thread_queue_Context_set_absolute_timeout(
Thread_queue_Context *queue_context,
uint64_t timeout
)
{
queue_context->timeout_discipline = WATCHDOG_ABSOLUTE;
queue_context->timeout = timeout;
}
/** /**
* @brief Sets the MP callout in the thread queue context. * @brief Sets the MP callout in the thread queue context.
* *
@@ -307,8 +359,8 @@ Thread_Control *_Thread_queue_Do_dequeue(
* @brief Blocks the thread and places it on the thread queue. * @brief Blocks the thread and places it on the thread queue.
* *
* This enqueues the thread on the thread queue, blocks the thread, and * This enqueues the thread on the thread queue, blocks the thread, and
* optionally starts the thread timer in case the timeout interval is not * optionally starts the thread timer in case the timeout discipline is not
* WATCHDOG_NO_TIMEOUT. * WATCHDOG_NO_TIMEOUT. Timeout discipline and value are in the queue_context.
* *
* The caller must be the owner of the thread queue lock. This function will * The caller must be the owner of the thread queue lock. This function will
* release the thread queue lock and register it as the new thread lock. * release the thread queue lock and register it as the new thread lock.
@@ -350,7 +402,6 @@ Thread_Control *_Thread_queue_Do_dequeue(
* MUTEX_TQ_OPERATIONS, * MUTEX_TQ_OPERATIONS,
* executing, * executing,
* STATES_WAITING_FOR_MUTEX, * STATES_WAITING_FOR_MUTEX,
* WATCHDOG_NO_TIMEOUT,
* 0, * 0,
* &queue_context * &queue_context
* ); * );
@@ -362,8 +413,6 @@ Thread_Control *_Thread_queue_Do_dequeue(
* @param[in] operations The thread queue operations. * @param[in] operations The thread queue operations.
* @param[in] the_thread The thread to enqueue. * @param[in] the_thread The thread to enqueue.
* @param[in] state The new state of the thread. * @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] queue_context The thread queue context of the lock acquire. * @param[in] queue_context The thread queue context of the lock acquire.
*/ */
void _Thread_queue_Enqueue_critical( void _Thread_queue_Enqueue_critical(
@@ -371,7 +420,6 @@ void _Thread_queue_Enqueue_critical(
const Thread_queue_Operations *operations, const Thread_queue_Operations *operations,
Thread_Control *the_thread, Thread_Control *the_thread,
States_Control state, States_Control state,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
); );
@@ -385,6 +433,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
Thread_Control *the_thread, Thread_Control *the_thread,
States_Control state, States_Control state,
Watchdog_Interval timeout, Watchdog_Interval timeout,
Watchdog_Discipline discipline,
uint32_t expected_level uint32_t expected_level
) )
{ {
@@ -393,12 +442,16 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
_Thread_queue_Context_initialize( &queue_context ); _Thread_queue_Context_initialize( &queue_context );
_Thread_queue_Acquire( the_thread_queue, &queue_context.Lock_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_expected_level( &queue_context, expected_level );
if ( discipline == WATCHDOG_ABSOLUTE ) {
_Thread_queue_Context_set_absolute_timeout( &queue_context, timeout );
} else {
_Thread_queue_Context_set_relative_timeout( &queue_context, timeout );
}
_Thread_queue_Enqueue_critical( _Thread_queue_Enqueue_critical(
&the_thread_queue->Queue, &the_thread_queue->Queue,
operations, operations,
the_thread, the_thread,
state, state,
timeout,
&queue_context &queue_context
); );
} }

View File

@@ -52,6 +52,38 @@ typedef struct Watchdog_Control Watchdog_Control;
*/ */
typedef uint32_t Watchdog_Interval; typedef uint32_t Watchdog_Interval;
/**
* @brief The clock discipline to use for the Watchdog timeout interval.
*/
typedef enum {
/**
* @brief Indefinite wait.
*
* This is to indicate there is no timeout and not to use a watchdog. It
* must be equal to 0, which is an illegal relative clock interval, so that
* it may be used as a Watchdog_Interval value with WATCHDOG_RELATIVE to
* express an indefinite wait.
*/
WATCHDOG_NO_TIMEOUT = 0,
/**
* @brief Relative clock.
*
* The reference time point for the watchdog is current ticks value
* during insert. Time is measured in clock ticks.
*/
WATCHDOG_RELATIVE,
/**
* @brief Absolute clock.
*
* The reference time point for this header is the POSIX Epoch. Time is
* measured in nanoseconds since POSIX Epoch.
*/
WATCHDOG_ABSOLUTE
} Watchdog_Discipline;
/** /**
* @brief Return type from a Watchdog Service Routine. * @brief Return type from a Watchdog Service Routine.
* *
@@ -67,14 +99,6 @@ typedef void Watchdog_Service_routine;
typedef Watchdog_Service_routine typedef Watchdog_Service_routine
( *Watchdog_Service_routine_entry )( Watchdog_Control * ); ( *Watchdog_Service_routine_entry )( Watchdog_Control * );
/**
* @brief The constant for indefinite wait.
*
* This is the constant for indefinite wait. It is actually an
* illegal interval.
*/
#define WATCHDOG_NO_TIMEOUT 0
/** /**
* @brief The watchdog header to manage scheduled watchdogs. * @brief The watchdog header to manage scheduled watchdogs.
*/ */

View File

@@ -340,45 +340,45 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_release_critical(
} }
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_relative( RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_relative(
Watchdog_Control *the_watchdog, Watchdog_Control *the_watchdog,
Per_CPU_Control *cpu, Per_CPU_Control *cpu,
uint32_t ticks Watchdog_Interval ticks
) )
{ {
ISR_lock_Context lock_context; ISR_lock_Context lock_context;
Watchdog_Header *header;
uint64_t expire; uint64_t expire;
_Watchdog_Set_CPU( the_watchdog, cpu ); _Watchdog_Set_CPU( the_watchdog, cpu );
_Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context );
expire = cpu->Watchdog.ticks + ticks;
_Watchdog_Insert(
&cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
the_watchdog,
expire
);
_Watchdog_Per_CPU_release_critical( cpu, &lock_context );
expire = ticks + cpu->Watchdog.ticks;
header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ];
_Watchdog_Insert(header, the_watchdog, expire);
_Watchdog_Per_CPU_release_critical( cpu, &lock_context );
return expire; return expire;
} }
RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_insert_absolute( RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_absolute(
Watchdog_Control *the_watchdog, Watchdog_Control *the_watchdog,
Per_CPU_Control *cpu, Per_CPU_Control *cpu,
uint64_t expire uint64_t expire
) )
{ {
ISR_lock_Context lock_context; ISR_lock_Context lock_context;
Watchdog_Header *header;
_Watchdog_Set_CPU( the_watchdog, cpu ); _Watchdog_Set_CPU( the_watchdog, cpu );
_Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context );
_Watchdog_Insert(
&cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ], header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ];
the_watchdog,
expire _Watchdog_Insert(header, the_watchdog, expire);
);
_Watchdog_Per_CPU_release_critical( cpu, &lock_context ); _Watchdog_Per_CPU_release_critical( cpu, &lock_context );
return expire;
} }
RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove( RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove(

View File

@@ -33,12 +33,11 @@ void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
_Thread_queue_Context_initialize( &queue_context ); _Thread_queue_Context_initialize( &queue_context );
_ISR_lock_ISR_disable( &queue_context.Lock_context ); _ISR_lock_ISR_disable( &queue_context.Lock_context );
_Thread_queue_Context_set_no_timeout( &queue_context );
_CORE_recursive_mutex_Seize( _CORE_recursive_mutex_Seize(
&the_mutex->Mutex, &the_mutex->Mutex,
_Thread_Executing, _Thread_Executing,
true, true,
WATCHDOG_NO_TIMEOUT,
_CORE_recursive_mutex_Seize_nested, _CORE_recursive_mutex_Seize_nested,
&queue_context &queue_context
); );

View File

@@ -82,7 +82,6 @@ static void _Condition_Queue_release(
static Per_CPU_Control *_Condition_Do_wait( static Per_CPU_Control *_Condition_Do_wait(
struct _Condition_Control *_condition, struct _Condition_Control *_condition,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -100,7 +99,6 @@ static Per_CPU_Control *_Condition_Do_wait(
CONDITION_TQ_OPERATIONS, CONDITION_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_SYS_LOCK_CONDITION, STATES_WAITING_FOR_SYS_LOCK_CONDITION,
timeout,
queue_context queue_context
); );
@@ -117,7 +115,11 @@ void _Condition_Wait(
_Thread_queue_Context_initialize( &queue_context ); _Thread_queue_Context_initialize( &queue_context );
_ISR_lock_ISR_disable( &queue_context.Lock_context ); _ISR_lock_ISR_disable( &queue_context.Lock_context );
cpu_self = _Condition_Do_wait( _condition, 0, &queue_context ); _Thread_queue_Context_set_no_timeout( &queue_context );
cpu_self = _Condition_Do_wait(
_condition,
&queue_context
);
_Mutex_Release( _mutex ); _Mutex_Release( _mutex );
_Thread_Dispatch_enable( cpu_self ); _Thread_Dispatch_enable( cpu_self );
@@ -151,7 +153,8 @@ int _Condition_Wait_timed(
break; break;
} }
cpu_self = _Condition_Do_wait( _condition, ticks, &queue_context ); _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
cpu_self = _Condition_Do_wait( _condition, &queue_context );
_Mutex_Release( _mutex ); _Mutex_Release( _mutex );
executing = cpu_self->executing; executing = cpu_self->executing;
@@ -173,7 +176,8 @@ void _Condition_Wait_recursive(
_Thread_queue_Context_initialize( &queue_context ); _Thread_queue_Context_initialize( &queue_context );
_ISR_lock_ISR_disable( &queue_context.Lock_context ); _ISR_lock_ISR_disable( &queue_context.Lock_context );
cpu_self = _Condition_Do_wait( _condition, 0, &queue_context ); _Thread_queue_Context_set_no_timeout( &queue_context );
cpu_self = _Condition_Do_wait( _condition, &queue_context );
nest_level = _mutex->_nest_level; nest_level = _mutex->_nest_level;
_mutex->_nest_level = 0; _mutex->_nest_level = 0;
@@ -211,7 +215,8 @@ int _Condition_Wait_recursive_timed(
break; break;
} }
cpu_self = _Condition_Do_wait( _condition, ticks, &queue_context ); _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
cpu_self = _Condition_Do_wait( _condition, &queue_context );
nest_level = _mutex->_nest_level; nest_level = _mutex->_nest_level;
_mutex->_nest_level = 0; _mutex->_nest_level = 0;

View File

@@ -26,7 +26,6 @@ Status_Control _CORE_barrier_Seize(
CORE_barrier_Control *the_barrier, CORE_barrier_Control *the_barrier,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -51,7 +50,6 @@ Status_Control _CORE_barrier_Seize(
CORE_BARRIER_TQ_OPERATIONS, CORE_BARRIER_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_BARRIER, STATES_WAITING_FOR_BARRIER,
timeout,
queue_context queue_context
); );
return _Thread_Wait_get_status( executing ); return _Thread_Wait_get_status( executing );

View File

@@ -31,7 +31,6 @@ Status_Control _CORE_message_queue_Seize(
void *buffer, void *buffer,
size_t *size_p, size_t *size_p,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -120,7 +119,6 @@ Status_Control _CORE_message_queue_Seize(
the_message_queue->operations, the_message_queue->operations,
executing, executing,
STATES_WAITING_FOR_MESSAGE, STATES_WAITING_FOR_MESSAGE,
timeout,
queue_context queue_context
); );
return _Thread_Wait_get_status( executing ); return _Thread_Wait_get_status( executing );

View File

@@ -33,7 +33,6 @@ Status_Control _CORE_message_queue_Submit(
size_t size, size_t size,
CORE_message_queue_Submit_types submit_type, CORE_message_queue_Submit_types submit_type,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -138,7 +137,6 @@ Status_Control _CORE_message_queue_Submit(
the_message_queue->operations, the_message_queue->operations,
executing, executing,
STATES_WAITING_FOR_MESSAGE, STATES_WAITING_FOR_MESSAGE,
timeout,
queue_context queue_context
); );
return _Thread_Wait_get_status( executing ); return _Thread_Wait_get_status( executing );

View File

@@ -21,13 +21,13 @@
#include <rtems/score/coremuteximpl.h> #include <rtems/score/coremuteximpl.h>
#include <rtems/score/statesimpl.h> #include <rtems/score/statesimpl.h>
#include <rtems/score/thread.h> #include <rtems/score/thread.h>
#include <rtems/score/watchdog.h>
Status_Control _CORE_mutex_Seize_slow( Status_Control _CORE_mutex_Seize_slow(
CORE_mutex_Control *the_mutex, CORE_mutex_Control *the_mutex,
Thread_Control *executing, Thread_Control *executing,
Thread_Control *owner, Thread_Control *owner,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -69,7 +69,6 @@ Status_Control _CORE_mutex_Seize_slow(
CORE_MUTEX_TQ_OPERATIONS, CORE_MUTEX_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_MUTEX, STATES_WAITING_FOR_MUTEX,
timeout,
queue_context queue_context
); );
@@ -85,7 +84,6 @@ Status_Control _CORE_mutex_Seize_no_protocol_slow(
const Thread_queue_Operations *operations, const Thread_queue_Operations *operations,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -96,7 +94,6 @@ Status_Control _CORE_mutex_Seize_no_protocol_slow(
operations, operations,
executing, executing,
STATES_WAITING_FOR_MUTEX, STATES_WAITING_FOR_MUTEX,
timeout,
queue_context queue_context
); );
return _Thread_Wait_get_status( executing ); return _Thread_Wait_get_status( executing );

View File

@@ -28,7 +28,6 @@ Status_Control _CORE_RWLock_Seize_for_reading(
CORE_RWLock_Control *the_rwlock, CORE_RWLock_Control *the_rwlock,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -85,7 +84,6 @@ Status_Control _CORE_RWLock_Seize_for_reading(
CORE_RWLOCK_TQ_OPERATIONS, CORE_RWLOCK_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_RWLOCK, STATES_WAITING_FOR_RWLOCK,
timeout,
queue_context queue_context
); );
return _Thread_Wait_get_status( executing ); return _Thread_Wait_get_status( executing );

View File

@@ -28,7 +28,6 @@ Status_Control _CORE_RWLock_Seize_for_writing(
CORE_RWLock_Control *the_rwlock, CORE_RWLock_Control *the_rwlock,
Thread_Control *executing, Thread_Control *executing,
bool wait, bool wait,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -73,7 +72,6 @@ Status_Control _CORE_RWLock_Seize_for_writing(
CORE_RWLOCK_TQ_OPERATIONS, CORE_RWLOCK_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_RWLOCK, STATES_WAITING_FOR_RWLOCK,
timeout,
queue_context queue_context
); );
return _Thread_Wait_get_status( executing ); return _Thread_Wait_get_status( executing );

View File

@@ -89,12 +89,12 @@ int _Futex_Wait( struct _Futex_Control *_futex, int *uaddr, int val )
if ( *uaddr == val ) { if ( *uaddr == val ) {
_Thread_queue_Context_set_expected_level( &queue_context, 1 ); _Thread_queue_Context_set_expected_level( &queue_context, 1 );
_Thread_queue_Context_set_no_timeout( &queue_context );
_Thread_queue_Enqueue_critical( _Thread_queue_Enqueue_critical(
&futex->Queue.Queue, &futex->Queue.Queue,
FUTEX_TQ_OPERATIONS, FUTEX_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_SYS_LOCK_FUTEX, STATES_WAITING_FOR_SYS_LOCK_FUTEX,
WATCHDOG_NO_TIMEOUT,
&queue_context &queue_context
); );
eno = 0; eno = 0;

View File

@@ -261,6 +261,7 @@ Status_Control _MPCI_Send_request_packet(
executing, executing,
STATES_WAITING_FOR_RPC_REPLY | extra_state, STATES_WAITING_FOR_RPC_REPLY | extra_state,
the_packet->timeout, the_packet->timeout,
WATCHDOG_RELATIVE,
2 2
); );
@@ -328,6 +329,7 @@ void _MPCI_Receive_server(
executing = _Thread_Get_executing(); executing = _Thread_Get_executing();
_Thread_queue_Context_initialize( &queue_context ); _Thread_queue_Context_initialize( &queue_context );
_Thread_queue_Context_set_no_timeout( &queue_context );
for ( ; ; ) { for ( ; ; ) {
@@ -339,7 +341,6 @@ void _MPCI_Receive_server(
MPCI_SEMAPHORE_TQ_OPERATIONS, MPCI_SEMAPHORE_TQ_OPERATIONS,
executing, executing,
true, true,
WATCHDOG_NO_TIMEOUT,
&queue_context &queue_context
); );

View File

@@ -104,7 +104,6 @@ static void _Mutex_Acquire_slow(
Mutex_Control *mutex, Mutex_Control *mutex,
Thread_Control *owner, Thread_Control *owner,
Thread_Control *executing, Thread_Control *executing,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -115,7 +114,6 @@ static void _Mutex_Acquire_slow(
MUTEX_TQ_OPERATIONS, MUTEX_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_SYS_LOCK_MUTEX, STATES_WAITING_FOR_SYS_LOCK_MUTEX,
timeout,
queue_context queue_context
); );
} }
@@ -219,7 +217,8 @@ void _Mutex_Acquire( struct _Mutex_Control *_mutex )
++executing->resource_count; ++executing->resource_count;
_Mutex_Queue_release( mutex, &queue_context ); _Mutex_Queue_release( mutex, &queue_context );
} else { } else {
_Mutex_Acquire_slow( mutex, owner, executing, 0, &queue_context ); _Thread_queue_Context_set_no_timeout( &queue_context );
_Mutex_Acquire_slow( mutex, owner, executing, &queue_context );
} }
} }
@@ -260,7 +259,8 @@ int _Mutex_Acquire_timed(
break; break;
} }
_Mutex_Acquire_slow( mutex, owner, executing, ticks, &queue_context ); _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
_Mutex_Acquire_slow( mutex, owner, executing, &queue_context );
return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) ); return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
} }
@@ -336,7 +336,8 @@ void _Mutex_recursive_Acquire( struct _Mutex_recursive_Control *_mutex )
++mutex->nest_level; ++mutex->nest_level;
_Mutex_Queue_release( &mutex->Mutex, &queue_context ); _Mutex_Queue_release( &mutex->Mutex, &queue_context );
} else { } else {
_Mutex_Acquire_slow( &mutex->Mutex, owner, executing, 0, &queue_context ); _Thread_queue_Context_set_no_timeout( &queue_context );
_Mutex_Acquire_slow( &mutex->Mutex, owner, executing, &queue_context );
} }
} }
@@ -382,13 +383,8 @@ int _Mutex_recursive_Acquire_timed(
break; break;
} }
_Mutex_Acquire_slow( _Thread_queue_Context_set_relative_timeout( &queue_context, ticks );
&mutex->Mutex, _Mutex_Acquire_slow( &mutex->Mutex, owner, executing, &queue_context );
owner,
executing,
ticks,
&queue_context
);
return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) ); return STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
} }

View File

@@ -101,12 +101,12 @@ void _Semaphore_Wait( struct _Semaphore_Control *_sem )
_Semaphore_Queue_release( sem, &queue_context ); _Semaphore_Queue_release( sem, &queue_context );
} else { } else {
_Thread_queue_Context_set_expected_level( &queue_context, 1 ); _Thread_queue_Context_set_expected_level( &queue_context, 1 );
_Thread_queue_Context_set_no_timeout( &queue_context );
_Thread_queue_Enqueue_critical( _Thread_queue_Enqueue_critical(
&sem->Queue.Queue, &sem->Queue.Queue,
SEMAPHORE_TQ_OPERATIONS, SEMAPHORE_TQ_OPERATIONS,
executing, executing,
STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE, STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE,
WATCHDOG_NO_TIMEOUT,
&queue_context &queue_context
); );
} }

View File

@@ -39,7 +39,6 @@ void _Thread_queue_Enqueue_critical(
const Thread_queue_Operations *operations, const Thread_queue_Operations *operations,
Thread_Control *the_thread, Thread_Control *the_thread,
States_Control state, States_Control state,
Watchdog_Interval timeout,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
@@ -83,13 +82,28 @@ void _Thread_queue_Enqueue_critical(
/* /*
* If the thread wants to timeout, then schedule its timer. * If the thread wants to timeout, then schedule its timer.
*/ */
if ( timeout != WATCHDOG_NO_TIMEOUT ) { switch ( queue_context->timeout_discipline ) {
_Thread_Timer_insert_relative( case WATCHDOG_RELATIVE:
the_thread, /* A relative timeout of 0 is a special case indefinite (no) timeout */
cpu_self, if ( queue_context->timeout != 0 ) {
_Thread_Timeout, _Thread_Timer_insert_relative(
timeout the_thread,
); cpu_self,
_Thread_Timeout,
(Watchdog_Interval) queue_context->timeout
);
}
break;
case WATCHDOG_ABSOLUTE:
_Thread_Timer_insert_absolute(
the_thread,
cpu_self,
_Thread_Timeout,
queue_context->timeout
);
break;
default:
break;
} }
/* /*

View File

@@ -479,7 +479,6 @@ void _Thread_Join(
THREAD_JOIN_TQ_OPERATIONS, THREAD_JOIN_TQ_OPERATIONS,
executing, executing,
waiting_for_join, waiting_for_join,
WATCHDOG_NO_TIMEOUT,
queue_context queue_context
); );
} }
@@ -546,6 +545,7 @@ void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing )
_Thread_queue_Context_initialize( &queue_context ); _Thread_queue_Context_initialize( &queue_context );
_Thread_queue_Context_set_expected_level( &queue_context, 2 ); _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 );
_Thread_Join( _Thread_Join(
the_thread, the_thread,