forked from Imagelibrary/rtems
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:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
* @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_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.
|
||||
*/
|
||||
#define THREAD_WAIT_STATE_INTERRUPT_TIMEOUT 0x20U
|
||||
#define THREAD_WAIT_STATE_READY_AGAIN 0x4U
|
||||
|
||||
/**
|
||||
* @brief Mask to get the thread wait class flags.
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user