diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-03-22 10:37:52 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-03-22 10:37:52 +0100 |
commit | 24297668a3c21d1fb579deea1c72ea932c8a105b (patch) | |
tree | d6d17bcfd0d3412b6e7337f30f699430ee22ef9c /cpukit/score/src/threadqenqueue.c | |
parent | sptests/spintrcritical23: Fix warnings (diff) | |
download | rtems-24297668a3c21d1fb579deea1c72ea932c8a105b.tar.bz2 |
score: Move _Thread_blocking_operation_Cancel()
Move _Thread_blocking_operation_Cancel() and make static since it is
only used by _Thread_queue_Enqueue_with_handler().
Move _Thread_blocking_operation_Finalize().
Diffstat (limited to 'cpukit/score/src/threadqenqueue.c')
-rw-r--r-- | cpukit/score/src/threadqenqueue.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index 0fa5fa6ae4..da2f554528 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -23,6 +23,95 @@ #include <rtems/score/threadimpl.h> #include <rtems/score/watchdogimpl.h> +void _Thread_blocking_operation_Finalize( + Thread_Control *the_thread, + ISR_Level level +) +{ + /* + * The thread is not waiting on anything after this completes. + */ + the_thread->Wait.queue = NULL; + + /* + * If the sync state is timed out, this is very likely not needed. + * But better safe than sorry when it comes to critical sections. + */ + if ( _Watchdog_Is_active( &the_thread->Timer ) ) { + _Watchdog_Deactivate( &the_thread->Timer ); + _ISR_Enable( level ); + (void) _Watchdog_Remove( &the_thread->Timer ); + } else + _ISR_Enable( level ); + + /* + * Global objects with thread queue's should not be operated on from an + * ISR. But the sync code still must allow short timeouts to be processed + * correctly. + */ + + _Thread_Unblock( the_thread ); + +#if defined(RTEMS_MULTIPROCESSING) + if ( !_Objects_Is_local_id( the_thread->Object.id ) ) + _Thread_MP_Free_proxy( the_thread ); +#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, |