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.
This commit is contained in:
Sebastian Huber
2015-04-26 15:22:20 +02:00
parent 776a50c47a
commit b7cff7feb0
5 changed files with 13 additions and 33 deletions

View File

@@ -85,7 +85,7 @@ void _Event_Surrender(
success = _Thread_Wait_flags_try_change_critical( success = _Thread_Wait_flags_try_change_critical(
the_thread, the_thread,
intend_to_block, intend_to_block,
wait_class | THREAD_WAIT_STATE_INTERRUPT_SATISFIED wait_class | THREAD_WAIT_STATE_READY_AGAIN
); );
if ( success ) { if ( success ) {
_Event_Satisfy( the_thread, event, pending_events, seized_events ); _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 ); _Event_Satisfy( the_thread, event, pending_events, seized_events );
_Thread_Wait_flags_set( _Thread_Wait_flags_set(
the_thread, the_thread,
wait_class | THREAD_WAIT_STATE_SATISFIED wait_class | THREAD_WAIT_STATE_READY_AGAIN
); );
unblock = true; unblock = true;
} else { } else {

View File

@@ -45,7 +45,7 @@ void _Event_Timeout(
success = _Thread_Wait_flags_try_change_critical( success = _Thread_Wait_flags_try_change_critical(
the_thread, the_thread,
intend_to_block, intend_to_block,
wait_class | THREAD_WAIT_STATE_INTERRUPT_TIMEOUT wait_class | THREAD_WAIT_STATE_READY_AGAIN
); );
if ( success ) { if ( success ) {
@@ -55,7 +55,7 @@ void _Event_Timeout(
the_thread->Wait.return_code = RTEMS_TIMEOUT; the_thread->Wait.return_code = RTEMS_TIMEOUT;
_Thread_Wait_flags_set( _Thread_Wait_flags_set(
the_thread, the_thread,
wait_class | THREAD_WAIT_STATE_TIMEOUT wait_class | THREAD_WAIT_STATE_READY_AGAIN
); );
unblock = true; unblock = true;
} else { } else {

View File

@@ -324,11 +324,8 @@ typedef union {
* *
* The mutually exclusive wait state flags are * The mutually exclusive wait state flags are
* - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK, * - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK,
* - @ref THREAD_WAIT_STATE_BLOCKED, * - @ref THREAD_WAIT_STATE_BLOCKED, and
* - @ref THREAD_WAIT_STATE_SATISFIED, * - @ref THREAD_WAIT_STATE_READY_AGAIN.
* - @ref THREAD_WAIT_STATE_TIMEOUT,
* - @ref THREAD_WAIT_STATE_INTERRUPT_SATISFIED, and
* - @ref THREAD_WAIT_STATE_INTERRUPT_TIMEOUT,
*/ */
typedef unsigned int Thread_Wait_flags; typedef unsigned int Thread_Wait_flags;

View File

@@ -1138,28 +1138,11 @@ RTEMS_INLINE_ROUTINE void _Thread_Priority_restore_default_change_handler(
#define THREAD_WAIT_STATE_BLOCKED 0x2U #define THREAD_WAIT_STATE_BLOCKED 0x2U
/** /**
* @brief Indicates that the thread progress condition is satisfied and it is * @brief Indicates that a condition to end the thread wait occurred.
* ready to resume execution. *
* This could be a timeout, a signal, an event or a resource availability.
*/ */
#define THREAD_WAIT_STATE_SATISFIED 0x4U #define THREAD_WAIT_STATE_READY_AGAIN 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.
*/
#define THREAD_WAIT_STATE_INTERRUPT_TIMEOUT 0x20U
/** /**
* @brief Mask to get the thread wait class flags. * @brief Mask to get the thread wait class flags.

View File

@@ -88,7 +88,7 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg)
if (ctx->hit) { if (ctx->hit) {
rtems_test_assert( rtems_test_assert(
_Thread_Wait_flags_get(thread) _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) { if (ctx->hit) {
rtems_test_assert( rtems_test_assert(
_Thread_Wait_flags_get(thread) _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) { if (ctx->hit) {
rtems_test_assert( rtems_test_assert(
_Thread_Wait_flags_get(thread) _Thread_Wait_flags_get(thread)
== (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_TIMEOUT) == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_READY_AGAIN)
); );
} }