summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-07-09 13:22:28 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-07-15 13:42:30 -0500
commit0ea6d07a030916ff1034e0152c7b56e652ee94f3 (patch)
tree42d69f4d62cd8cac3d6582492dfb618dac70e436 /cpukit/score/src
parentThread Queue: Merge discipline subroutines into main methods (diff)
downloadrtems-0ea6d07a030916ff1034e0152c7b56e652ee94f3.tar.bz2
Use Shared Method for Thread Unblock Cleanup
When a thread is removed from a thread queue or is unblocked by receiving an event, the same actions are required. + timeout watchdog canceled, + thread must be unblocked, and + (MP only) proxy cleaned up This patch makes sure there is only one copy of this code.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/threadblockingoperationcancel.c65
-rw-r--r--cpukit/score/src/threadqdequeue.c18
-rw-r--r--cpukit/score/src/threadqextract.c22
3 files changed, 45 insertions, 60 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 );
}
diff --git a/cpukit/score/src/threadqdequeue.c b/cpukit/score/src/threadqdequeue.c
index 3b55e52e83..d745ef29e3 100644
--- a/cpukit/score/src/threadqdequeue.c
+++ b/cpukit/score/src/threadqdequeue.c
@@ -70,22 +70,10 @@ Thread_Control *_Thread_queue_Dequeue(
/*
* We found a thread to unblock.
+ *
+ * NOTE: This is invoked with interrupts still disabled.
*/
- the_thread->Wait.queue = NULL;
- if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
- _ISR_Enable( level );
- } else {
- _Watchdog_Deactivate( &the_thread->Timer );
- _ISR_Enable( level );
- (void) _Watchdog_Remove( &the_thread->Timer );
- }
-
- _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 );
return the_thread;
}
diff --git a/cpukit/score/src/threadqextract.c b/cpukit/score/src/threadqextract.c
index bc7d34686a..d12d3c889a 100644
--- a/cpukit/score/src/threadqextract.c
+++ b/cpukit/score/src/threadqextract.c
@@ -48,24 +48,14 @@ void _Thread_queue_Extract_with_return_code(
);
}
- the_thread->Wait.queue = NULL;
the_thread->Wait.return_code = return_code;
- if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
- _ISR_Enable( level );
- } else {
- _Watchdog_Deactivate( &the_thread->Timer );
- _ISR_Enable( level );
- (void) _Watchdog_Remove( &the_thread->Timer );
- }
-
- _Thread_Unblock( the_thread );
-
-#if defined(RTEMS_MULTIPROCESSING)
- if ( !_Objects_Is_local_id( the_thread->Object.id ) )
- _Thread_MP_Free_proxy( the_thread );
-#endif
-
+ /*
+ * We found a thread to unblock.
+ *
+ * NOTE: This is invoked with interrupts still disabled.
+ */
+ _Thread_blocking_operation_Finalize( the_thread, level );
}
void _Thread_queue_Extract(