score: Simplify debug code and use _Assert()

This commit is contained in:
Sebastian Huber
2015-03-22 14:31:59 +01:00
parent d2bdf5cc4d
commit a6524b9ca7
4 changed files with 13 additions and 60 deletions

View File

@@ -44,7 +44,7 @@ static const char *const internal_error_text[] = {
"INTERNAL_ERROR_BAD_STACK_HOOK",
"INTERNAL_ERROR_BAD_ATTRIBUTES",
"INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY",
"INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL",
"OBSOLETE_INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL",
"INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE",
"INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0",
"OBSOLETE_INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP",

View File

@@ -153,7 +153,7 @@ typedef enum {
INTERNAL_ERROR_BAD_STACK_HOOK,
INTERNAL_ERROR_BAD_ATTRIBUTES,
INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY,
INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL,
OBSOLETE_INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL,
INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE,
INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0,
OBSOLETE_INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP,

View File

@@ -19,6 +19,7 @@
#endif
#include <rtems/score/threadqimpl.h>
#include <rtems/score/assert.h>
#include <rtems/score/isrlevel.h>
#include <rtems/score/rbtreeimpl.h>
#include <rtems/score/threadimpl.h>
@@ -72,60 +73,6 @@ static void _Thread_blocking_operation_Finalize(
#endif
}
/**
* @brief Cancel a blocking operation due to ISR.
*
* This method is used to cancel a blocking operation that was
* satisfied from an ISR while the thread executing was in the
* process of blocking.
*
* This method will restore the previous ISR disable level during the cancel
* operation. Thus it is an implicit _ISR_Enable().
*
* @param[in] sync_state is the synchronization state
* @param[in] the_thread is the thread whose blocking is canceled
* @param[in] level is the previous ISR disable level
*
* @note This is a rare routine in RTEMS. It is called with
* interrupts disabled and only when an ISR completed
* a blocking condition in process.
*/
static void _Thread_blocking_operation_Cancel(
Thread_blocking_operation_States sync_state,
Thread_Control *the_thread,
ISR_Level level
)
{
/*
* Cases that should not happen and why.
*
* THREAD_BLOCKING_OPERATION_SYNCHRONIZED:
*
* This indicates that someone did not enter a blocking
* operation critical section.
*
* THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED:
*
* This indicates that there was nothing to cancel so
* we should not have been called.
*/
#if defined(RTEMS_DEBUG)
if ( (sync_state == THREAD_BLOCKING_OPERATION_SYNCHRONIZED) ||
(sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ) {
_Terminate(
INTERNAL_ERROR_CORE,
true,
INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
);
}
#else
(void) sync_state;
#endif
_Thread_blocking_operation_Finalize( the_thread, level );
}
void _Thread_queue_Enqueue_with_handler(
Thread_queue_Control *the_thread_queue,
Thread_Control *the_thread,
@@ -191,9 +138,15 @@ void _Thread_queue_Enqueue_with_handler(
the_thread->Wait.queue = the_thread_queue;
the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
_ISR_Enable( level );
return;
} else { /* sync_state != THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) */
_Thread_blocking_operation_Cancel( sync_state, the_thread, level );
} else {
/* Cancel a blocking operation due to ISR */
_Assert(
sync_state == THREAD_BLOCKING_OPERATION_TIMEOUT ||
sync_state == THREAD_BLOCKING_OPERATION_SATISFIED
);
_Thread_blocking_operation_Finalize( the_thread, level );
}
}

View File

@@ -16,7 +16,7 @@ INTERNAL_ERROR_INVALID_GLOBAL_ID
INTERNAL_ERROR_BAD_STACK_HOOK
INTERNAL_ERROR_BAD_ATTRIBUTES
INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY
INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
OBSOLETE_INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE
INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0
OBSOLETE_INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP