summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadblockingoperationcancel.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-22 18:28:53 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-22 18:28:53 +0000
commit3168deaa10fae157b38a94c5204a66d28a43ad7a (patch)
tree0bda84e785960fa6641c2b167d626cf3271b3352 /cpukit/score/src/threadblockingoperationcancel.c
parent2008-01-22 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-3168deaa10fae157b38a94c5204a66d28a43ad7a.tar.bz2
2008-01-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* rtems/include/rtems/rtems/event.h, rtems/inline/rtems/rtems/eventset.inl, rtems/src/event.c, rtems/src/eventseize.c, rtems/src/eventsurrender.c, rtems/src/eventtimeout.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/interr.h, score/include/rtems/score/thread.h, score/include/rtems/score/threadq.h, score/include/rtems/score/tqdata.h, score/inline/rtems/score/threadq.inl, score/inline/rtems/score/tqdata.inl, score/src/threadq.c, score/src/threadqdequeue.c, score/src/threadqdequeuefifo.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueue.c, score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c, score/src/threadqextract.c, score/src/threadqextractfifo.c, score/src/threadqextractpriority.c, score/src/threadqextractwithproxy.c, score/src/threadqfirst.c, score/src/threadqfirstfifo.c, score/src/threadqfirstpriority.c, score/src/threadqflush.c, score/src/threadqrequeue.c, score/src/threadqtimeout.c: Refactor thread queue enqueue and event blocking synchronization critical sections. This resulted in three copies of essentially the same hard to test critical section code becoming the one shared routine _Thread_blocking_operation_Cancel. In addition, the thread queue and event code now share a common synchronization enumerated type. Along the way, switches were reworked to eliminate dead code generated by gcc and comments and copyrights were updated. * score/include/rtems/score/threadsync.h, score/src/threadblockingoperationcancel.c: New files.
Diffstat (limited to 'cpukit/score/src/threadblockingoperationcancel.c')
-rw-r--r--cpukit/score/src/threadblockingoperationcancel.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/cpukit/score/src/threadblockingoperationcancel.c b/cpukit/score/src/threadblockingoperationcancel.c
new file mode 100644
index 0000000000..b2b7a22745
--- /dev/null
+++ b/cpukit/score/src/threadblockingoperationcancel.c
@@ -0,0 +1,81 @@
+/*
+ * Cancel Thread Blocking Operation
+ *
+ *
+ * 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.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/score/thread.h>
+#if defined(RTEMS_MULTIPROCESSING)
+#include <rtems/score/mpci.h>
+#endif
+
+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) ) {
+ _Internal_error_Occurred(
+ INTERNAL_ERROR_CORE,
+ TRUE,
+ INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
+ );
+ }
+ #endif
+
+ /*
+ * 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 );
+ the_thread->Wait.queue = NULL;
+ _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
+
+}