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 | |
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().
-rw-r--r-- | cpukit/score/Makefile.am | 3 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadimpl.h | 24 | ||||
-rw-r--r-- | cpukit/score/src/threadblockingoperationcancel.c | 98 | ||||
-rw-r--r-- | cpukit/score/src/threadqenqueue.c | 89 |
4 files changed, 90 insertions, 124 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index ad2b3048e8..031c9a8b2d 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -288,8 +288,7 @@ libscore_a_SOURCES += src/thread.c src/threadchangepriority.c \ src/threadrestart.c src/threadsetpriority.c \ src/threadsetstate.c \ src/threadstackallocate.c src/threadstackfree.c src/threadstart.c \ - src/threadstartmultitasking.c src/iterateoverthreads.c \ - src/threadblockingoperationcancel.c + src/threadstartmultitasking.c src/iterateoverthreads.c libscore_a_SOURCES += src/threadglobalconstruction.c libscore_a_SOURCES += src/threadyield.c diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index 9d98fe863f..d7c2ea2052 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -418,30 +418,6 @@ Thread_Control *_Thread_Acquire( Thread_Control *_Thread_Acquire_executing( ISR_lock_Context *lock_context ); /** - * @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. - */ -void _Thread_blocking_operation_Cancel( - Thread_blocking_operation_States sync_state, - Thread_Control *the_thread, - ISR_Level level -); - -/** * @brief Finalize a blocking operation. * * This method is used to finalize a blocking operation that was diff --git a/cpukit/score/src/threadblockingoperationcancel.c b/cpukit/score/src/threadblockingoperationcancel.c deleted file mode 100644 index b4967964b7..0000000000 --- a/cpukit/score/src/threadblockingoperationcancel.c +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file - * - * @brief Cancel a Blocking Operation - * @ingroup ScoreThread - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/score/threadimpl.h> -#if defined(RTEMS_DEBUG) -#include <rtems/score/interr.h> -#endif -#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 -} - -void _Thread_blocking_operation_Cancel( -#if defined(RTEMS_DEBUG) - Thread_blocking_operation_States sync_state, -#else - Thread_blocking_operation_States sync_state __attribute__((unused)), -#endif - 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 - ); - } - #endif - - _Thread_blocking_operation_Finalize( the_thread, level ); -} 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, |