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/include/rtems/score | |
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 '')
-rw-r--r-- | cpukit/score/include/rtems/score/corebarrierimpl.h | 5 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/coremsgimpl.h | 10 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/coremuteximpl.h | 8 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/corerwlockimpl.h | 6 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/coresemimpl.h | 3 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/mrspimpl.h | 5 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadimpl.h | 11 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadq.h | 12 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadqimpl.h | 67 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/watchdog.h | 40 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/watchdogimpl.h | 38 |
11 files changed, 132 insertions, 73 deletions
diff --git a/cpukit/score/include/rtems/score/corebarrierimpl.h b/cpukit/score/include/rtems/score/corebarrierimpl.h index d2d9997d95..a7256b9d6d 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 d240c4a405..3b811c920d 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 3a5ae99a95..339834bc37 100644 --- a/cpukit/score/include/rtems/score/coremuteximpl.h +++ b/cpukit/score/include/rtems/score/coremuteximpl.h @@ -100,7 +100,6 @@ Status_Control _CORE_mutex_Seize_slow( Thread_Control *executing, Thread_Control *owner, bool wait, - Watchdog_Interval timeout, Thread_queue_Context *queue_context ); @@ -109,7 +108,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 ); @@ -183,7 +181,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 ) @@ -214,7 +211,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize( executing, owner, wait, - timeout, queue_context ); } @@ -277,7 +273,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 ) @@ -307,7 +302,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_no_protocol( operations, executing, wait, - timeout, queue_context ); } @@ -434,7 +428,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 ) @@ -476,7 +469,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 e80ab0ef0c..ff881fa186 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 487a91b3c7..5a287263aa 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,7 +196,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize( operations, executing, STATES_WAITING_FOR_SEMAPHORE, - timeout, 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 66f5cc6640..c136a2037c 100644 --- a/cpukit/score/include/rtems/score/mrspimpl.h +++ b/cpukit/score/include/rtems/score/mrspimpl.h @@ -240,7 +240,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 ) { @@ -250,6 +249,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; + _Assert( queue_context->timeout_discipline == WATCHDOG_RELATIVE ); rival.thread = executing; rival.resource = mrsp; @@ -317,7 +318,6 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize( MRSP_Control *mrsp, Thread_Control *executing, bool wait, - Watchdog_Interval timeout, Thread_queue_Context *queue_context ) { @@ -357,7 +357,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/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index 448f38d6fc..478ab3a334 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -1511,7 +1511,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_relative( _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; _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, Per_CPU_Control *cpu, Watchdog_Service_routine_entry routine, - uint64_t expire + uint64_t ticks ) { ISR_lock_Context 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; - _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 ); } + + + RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread ) { ISR_lock_Context lock_context; diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h index a4e5292f34..b3b8fec980 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,17 @@ typedef struct { 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 * proxy. * diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h index 986edc3482..2d396cb7ed 100644 --- a/cpukit/score/include/rtems/score/threadqimpl.h +++ b/cpukit/score/include/rtems/score/threadqimpl.h @@ -91,6 +91,58 @@ _Thread_queue_Context_set_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. * * @param queue_context 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. * * This enqueues the thread on the thread queue, blocks the thread, and - * optionally starts the thread timer in case the timeout interval is not - * WATCHDOG_NO_TIMEOUT. + * optionally starts the thread timer in case the timeout discipline is not + * 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 * 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, * executing, * STATES_WAITING_FOR_MUTEX, - * WATCHDOG_NO_TIMEOUT, * 0, * &queue_context * ); @@ -362,8 +413,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] queue_context The thread queue context of the lock acquire. */ void _Thread_queue_Enqueue_critical( @@ -371,7 +420,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 ); @@ -385,6 +433,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue( Thread_Control *the_thread, States_Control state, Watchdog_Interval timeout, + Watchdog_Discipline discipline, uint32_t expected_level ) { @@ -393,12 +442,16 @@ 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 ); + 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( &the_thread_queue->Queue, operations, the_thread, state, - timeout, &queue_context ); } diff --git a/cpukit/score/include/rtems/score/watchdog.h b/cpukit/score/include/rtems/score/watchdog.h index c582dbd1ae..11a5974c26 100644 --- a/cpukit/score/include/rtems/score/watchdog.h +++ b/cpukit/score/include/rtems/score/watchdog.h @@ -53,6 +53,38 @@ typedef struct Watchdog_Control Watchdog_Control; 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. * * This type defines the return type from a Watchdog Service Routine. @@ -68,14 +100,6 @@ typedef Watchdog_Service_routine ( *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. */ typedef struct { diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h index c5f8d209a6..0900a1b8e7 100644 --- a/cpukit/score/include/rtems/score/watchdogimpl.h +++ b/cpukit/score/include/rtems/score/watchdogimpl.h @@ -340,45 +340,45 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_release_critical( } RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_relative( - Watchdog_Control *the_watchdog, - Per_CPU_Control *cpu, - uint32_t ticks + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu, + Watchdog_Interval ticks ) { ISR_lock_Context lock_context; + Watchdog_Header *header; uint64_t expire; _Watchdog_Set_CPU( the_watchdog, cpu ); _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; } -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_insert_absolute( - Watchdog_Control *the_watchdog, - Per_CPU_Control *cpu, - uint64_t expire +RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_absolute( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu, + uint64_t expire ) { ISR_lock_Context lock_context; + Watchdog_Header *header; _Watchdog_Set_CPU( the_watchdog, cpu ); _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); - _Watchdog_Insert( - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ], - the_watchdog, - expire - ); + + header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ]; + + _Watchdog_Insert(header, the_watchdog, expire); _Watchdog_Per_CPU_release_critical( cpu, &lock_context ); + return expire; } RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove( |