diff options
Diffstat (limited to 'cpukit/score/src/threadblockingoperationcancel.c')
-rw-r--r-- | cpukit/score/src/threadblockingoperationcancel.c | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/cpukit/score/src/threadblockingoperationcancel.c b/cpukit/score/src/threadblockingoperationcancel.c index 127d852de2..b4967964b7 100644 --- a/cpukit/score/src/threadblockingoperationcancel.c +++ b/cpukit/score/src/threadblockingoperationcancel.c @@ -24,6 +24,41 @@ #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, @@ -59,33 +94,5 @@ void _Thread_blocking_operation_Cancel( } #endif - /* - * 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 - + _Thread_blocking_operation_Finalize( the_thread, level ); } |