diff options
author | Gedare Bloom <gedare@rtems.org> | 2016-06-09 11:33:15 -0400 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2016-07-25 12:44:47 -0400 |
commit | f23d4706169d68d3c4e90b297650f89c272716f4 (patch) | |
tree | 333bdc4b4be2ec4ad7ee80ee03229759ec60602a /cpukit/score/src | |
parent | score: Fix for RTEMS_DEBUG (diff) | |
download | rtems-f23d4706169d68d3c4e90b297650f89c272716f4.tar.bz2 |
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
Diffstat (limited to 'cpukit/score/src')
-rw-r--r-- | cpukit/score/src/apimutexlock.c | 3 | ||||
-rw-r--r-- | cpukit/score/src/condition.c | 17 | ||||
-rw-r--r-- | cpukit/score/src/corebarrierwait.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremsgseize.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremsgsubmit.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremutexseize.c | 5 | ||||
-rw-r--r-- | cpukit/score/src/corerwlockobtainread.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/corerwlockobtainwrite.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/futex.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/mpci.c | 3 | ||||
-rw-r--r-- | cpukit/score/src/mutex.c | 20 | ||||
-rw-r--r-- | cpukit/score/src/semaphore.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadqenqueue.c | 30 | ||||
-rw-r--r-- | cpukit/score/src/threadrestart.c | 2 |
14 files changed, 48 insertions, 46 deletions
diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c index df53e75256..f69cfdea64 100644 --- a/cpukit/score/src/apimutexlock.c +++ b/cpukit/score/src/apimutexlock.c @@ -33,12 +33,11 @@ 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_no_timeout( &queue_context ); _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 e7d98058a0..90717bc93e 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,7 +99,6 @@ static Per_CPU_Control *_Condition_Do_wait( CONDITION_TQ_OPERATIONS, executing, STATES_WAITING_FOR_SYS_LOCK_CONDITION, - timeout, queue_context ); @@ -117,7 +115,11 @@ 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_no_timeout( &queue_context ); + cpu_self = _Condition_Do_wait( + _condition, + &queue_context + ); _Mutex_Release( _mutex ); _Thread_Dispatch_enable( cpu_self ); @@ -151,7 +153,8 @@ int _Condition_Wait_timed( 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 ); executing = cpu_self->executing; @@ -173,7 +176,8 @@ 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_no_timeout( &queue_context ); + cpu_self = _Condition_Do_wait( _condition, &queue_context ); nest_level = _mutex->_nest_level; _mutex->_nest_level = 0; @@ -211,7 +215,8 @@ int _Condition_Wait_recursive_timed( 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; _mutex->_nest_level = 0; diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c index d939acf69b..7e46c93670 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,7 +50,6 @@ Status_Control _CORE_barrier_Seize( CORE_BARRIER_TQ_OPERATIONS, executing, STATES_WAITING_FOR_BARRIER, - timeout, queue_context ); return _Thread_Wait_get_status( executing ); diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c index 6906328039..d86afd08de 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,7 +119,6 @@ Status_Control _CORE_message_queue_Seize( the_message_queue->operations, executing, STATES_WAITING_FOR_MESSAGE, - timeout, queue_context ); return _Thread_Wait_get_status( executing ); diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c index fb56ffed4a..97b43823c3 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,7 +137,6 @@ Status_Control _CORE_message_queue_Submit( the_message_queue->operations, executing, STATES_WAITING_FOR_MESSAGE, - timeout, queue_context ); return _Thread_Wait_get_status( executing ); diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c index ab743c4847..c468c07a7c 100644 --- a/cpukit/score/src/coremutexseize.c +++ b/cpukit/score/src/coremutexseize.c @@ -21,13 +21,13 @@ #include <rtems/score/coremuteximpl.h> #include <rtems/score/statesimpl.h> #include <rtems/score/thread.h> +#include <rtems/score/watchdog.h> Status_Control _CORE_mutex_Seize_slow( CORE_mutex_Control *the_mutex, Thread_Control *executing, Thread_Control *owner, bool wait, - Watchdog_Interval timeout, Thread_queue_Context *queue_context ) { @@ -69,7 +69,6 @@ Status_Control _CORE_mutex_Seize_slow( CORE_MUTEX_TQ_OPERATIONS, executing, STATES_WAITING_FOR_MUTEX, - timeout, queue_context ); @@ -85,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 ) { @@ -96,7 +94,6 @@ Status_Control _CORE_mutex_Seize_no_protocol_slow( operations, executing, STATES_WAITING_FOR_MUTEX, - timeout, queue_context ); return _Thread_Wait_get_status( executing ); diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c index bce992c1b0..09b26afd27 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,7 +84,6 @@ Status_Control _CORE_RWLock_Seize_for_reading( CORE_RWLOCK_TQ_OPERATIONS, executing, STATES_WAITING_FOR_RWLOCK, - timeout, queue_context ); return _Thread_Wait_get_status( executing ); diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c index c261d32f3f..9aac5e7ef7 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,7 +72,6 @@ Status_Control _CORE_RWLock_Seize_for_writing( CORE_RWLOCK_TQ_OPERATIONS, executing, STATES_WAITING_FOR_RWLOCK, - timeout, queue_context ); return _Thread_Wait_get_status( executing ); diff --git a/cpukit/score/src/futex.c b/cpukit/score/src/futex.c index a192509f5c..840101a703 100644 --- a/cpukit/score/src/futex.c +++ b/cpukit/score/src/futex.c @@ -89,12 +89,12 @@ 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_no_timeout( &queue_context ); _Thread_queue_Enqueue_critical( &futex->Queue.Queue, FUTEX_TQ_OPERATIONS, executing, STATES_WAITING_FOR_SYS_LOCK_FUTEX, - WATCHDOG_NO_TIMEOUT, &queue_context ); eno = 0; diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c index 9eb169ba17..a562b29cbd 100644 --- a/cpukit/score/src/mpci.c +++ b/cpukit/score/src/mpci.c @@ -261,6 +261,7 @@ Status_Control _MPCI_Send_request_packet( executing, STATES_WAITING_FOR_RPC_REPLY | extra_state, the_packet->timeout, + WATCHDOG_RELATIVE, 2 ); @@ -328,6 +329,7 @@ void _MPCI_Receive_server( executing = _Thread_Get_executing(); _Thread_queue_Context_initialize( &queue_context ); + _Thread_queue_Context_set_no_timeout( &queue_context ); for ( ; ; ) { @@ -339,7 +341,6 @@ void _MPCI_Receive_server( MPCI_SEMAPHORE_TQ_OPERATIONS, executing, true, - WATCHDOG_NO_TIMEOUT, &queue_context ); diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c index ed374a0768..ed600b3ec2 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,7 +114,6 @@ static void _Mutex_Acquire_slow( MUTEX_TQ_OPERATIONS, executing, STATES_WAITING_FOR_SYS_LOCK_MUTEX, - timeout, queue_context ); } @@ -219,7 +217,8 @@ 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_no_timeout( &queue_context ); + _Mutex_Acquire_slow( mutex, owner, executing, &queue_context ); } } @@ -260,7 +259,8 @@ int _Mutex_Acquire_timed( 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 ) ); } @@ -336,7 +336,8 @@ 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_no_timeout( &queue_context ); + _Mutex_Acquire_slow( &mutex->Mutex, owner, executing, &queue_context ); } } @@ -382,13 +383,8 @@ int _Mutex_recursive_Acquire_timed( break; } - _Mutex_Acquire_slow( - &mutex->Mutex, - owner, - executing, - ticks, - &queue_context - ); + _Thread_queue_Context_set_relative_timeout( &queue_context, ticks ); + _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 03af9cff7e..72cb1c796d 100644 --- a/cpukit/score/src/semaphore.c +++ b/cpukit/score/src/semaphore.c @@ -101,12 +101,12 @@ 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_no_timeout( &queue_context ); _Thread_queue_Enqueue_critical( &sem->Queue.Queue, SEMAPHORE_TQ_OPERATIONS, executing, STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE, - WATCHDOG_NO_TIMEOUT, &queue_context ); } diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index 3be7d58f16..088157d20c 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -39,7 +39,6 @@ void _Thread_queue_Enqueue_critical( const Thread_queue_Operations *operations, Thread_Control *the_thread, States_Control state, - Watchdog_Interval timeout, 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 ( timeout != WATCHDOG_NO_TIMEOUT ) { - _Thread_Timer_insert_relative( - the_thread, - cpu_self, - _Thread_Timeout, - timeout - ); + switch ( queue_context->timeout_discipline ) { + case WATCHDOG_RELATIVE: + /* A relative timeout of 0 is a special case indefinite (no) timeout */ + if ( queue_context->timeout != 0 ) { + _Thread_Timer_insert_relative( + 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; } /* diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index b43c019b69..757f552699 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -479,7 +479,6 @@ void _Thread_Join( THREAD_JOIN_TQ_OPERATIONS, executing, waiting_for_join, - WATCHDOG_NO_TIMEOUT, 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_set_expected_level( &queue_context, 2 ); + _Thread_queue_Context_set_no_timeout( &queue_context ); _Thread_State_acquire( the_thread, &queue_context.Lock_context ); _Thread_Join( the_thread, |