From b7cff7feb0a0d41ec4876e5ac846bb6cf8254dce Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Sun, 26 Apr 2015 15:22:20 +0200 Subject: score: Reduce thread wait states Merge THREAD_WAIT_STATE_SATISFIED, THREAD_WAIT_STATE_TIMEOUT, THREAD_WAIT_STATE_INTERRUPT_SATISFIED, and THREAD_WAIT_STATE_INTERRUPT_TIMEOUT into one state THREAD_WAIT_STATE_READY_AGAIN. This helps to write generic routines to block a thread. Update #2273. --- cpukit/rtems/src/eventsurrender.c | 4 ++-- cpukit/rtems/src/eventtimeout.c | 4 ++-- cpukit/score/include/rtems/score/thread.h | 7 ++----- cpukit/score/include/rtems/score/threadimpl.h | 25 ++++--------------------- testsuites/sptests/spintrcritical10/init.c | 6 +++--- 5 files changed, 13 insertions(+), 33 deletions(-) diff --git a/cpukit/rtems/src/eventsurrender.c b/cpukit/rtems/src/eventsurrender.c index e29d203f71..b740721e22 100644 --- a/cpukit/rtems/src/eventsurrender.c +++ b/cpukit/rtems/src/eventsurrender.c @@ -85,7 +85,7 @@ void _Event_Surrender( success = _Thread_Wait_flags_try_change_critical( the_thread, intend_to_block, - wait_class | THREAD_WAIT_STATE_INTERRUPT_SATISFIED + wait_class | THREAD_WAIT_STATE_READY_AGAIN ); if ( success ) { _Event_Satisfy( the_thread, event, pending_events, seized_events ); @@ -94,7 +94,7 @@ void _Event_Surrender( _Event_Satisfy( the_thread, event, pending_events, seized_events ); _Thread_Wait_flags_set( the_thread, - wait_class | THREAD_WAIT_STATE_SATISFIED + wait_class | THREAD_WAIT_STATE_READY_AGAIN ); unblock = true; } else { diff --git a/cpukit/rtems/src/eventtimeout.c b/cpukit/rtems/src/eventtimeout.c index 9c091748c0..5db118b183 100644 --- a/cpukit/rtems/src/eventtimeout.c +++ b/cpukit/rtems/src/eventtimeout.c @@ -45,7 +45,7 @@ void _Event_Timeout( success = _Thread_Wait_flags_try_change_critical( the_thread, intend_to_block, - wait_class | THREAD_WAIT_STATE_INTERRUPT_TIMEOUT + wait_class | THREAD_WAIT_STATE_READY_AGAIN ); if ( success ) { @@ -55,7 +55,7 @@ void _Event_Timeout( the_thread->Wait.return_code = RTEMS_TIMEOUT; _Thread_Wait_flags_set( the_thread, - wait_class | THREAD_WAIT_STATE_TIMEOUT + wait_class | THREAD_WAIT_STATE_READY_AGAIN ); unblock = true; } else { diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index 72e011ccff..112bd22e63 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -324,11 +324,8 @@ typedef union { * * The mutually exclusive wait state flags are * - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK, - * - @ref THREAD_WAIT_STATE_BLOCKED, - * - @ref THREAD_WAIT_STATE_SATISFIED, - * - @ref THREAD_WAIT_STATE_TIMEOUT, - * - @ref THREAD_WAIT_STATE_INTERRUPT_SATISFIED, and - * - @ref THREAD_WAIT_STATE_INTERRUPT_TIMEOUT, + * - @ref THREAD_WAIT_STATE_BLOCKED, and + * - @ref THREAD_WAIT_STATE_READY_AGAIN. */ typedef unsigned int Thread_Wait_flags; diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index 84c9ac316f..3577a7493b 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -1138,28 +1138,11 @@ RTEMS_INLINE_ROUTINE void _Thread_Priority_restore_default_change_handler( #define THREAD_WAIT_STATE_BLOCKED 0x2U /** - * @brief Indicates that the thread progress condition is satisfied and it is - * ready to resume execution. - */ -#define THREAD_WAIT_STATE_SATISFIED 0x4U - -/** - * @brief Indicates that a timeout occurred and the thread is ready to resume - * execution. - */ -#define THREAD_WAIT_STATE_TIMEOUT 0x8U - -/** - * @brief Indicates that the thread progress condition was satisfied during the - * blocking operation and it is ready to resume execution. - */ -#define THREAD_WAIT_STATE_INTERRUPT_SATISFIED 0x10U - -/** - * @brief Indicates that a timeout occurred during the blocking operation and - * the thread is ready to resume execution. + * @brief Indicates that a condition to end the thread wait occurred. + * + * This could be a timeout, a signal, an event or a resource availability. */ -#define THREAD_WAIT_STATE_INTERRUPT_TIMEOUT 0x20U +#define THREAD_WAIT_STATE_READY_AGAIN 0x4U /** * @brief Mask to get the thread wait class flags. diff --git a/testsuites/sptests/spintrcritical10/init.c b/testsuites/sptests/spintrcritical10/init.c index 441b161b5b..e9f813d521 100644 --- a/testsuites/sptests/spintrcritical10/init.c +++ b/testsuites/sptests/spintrcritical10/init.c @@ -88,7 +88,7 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg) if (ctx->hit) { rtems_test_assert( _Thread_Wait_flags_get(thread) - == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_SATISFIED) + == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_READY_AGAIN) ); } @@ -185,7 +185,7 @@ static void all_satisfy_before_timeout(rtems_id timer, void *arg) if (ctx->hit) { rtems_test_assert( _Thread_Wait_flags_get(thread) - == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_SATISFIED) + == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_READY_AGAIN) ); } @@ -269,7 +269,7 @@ static void timeout_before_satisfied(rtems_id timer, void *arg) if (ctx->hit) { rtems_test_assert( _Thread_Wait_flags_get(thread) - == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_TIMEOUT) + == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_READY_AGAIN) ); } -- cgit v1.2.3