From 3168deaa10fae157b38a94c5204a66d28a43ad7a Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 22 Jan 2008 18:28:53 +0000 Subject: 2008-01-22 Joel Sherrill * 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. --- cpukit/rtems/src/eventtimeout.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'cpukit/rtems/src/eventtimeout.c') diff --git a/cpukit/rtems/src/eventtimeout.c b/cpukit/rtems/src/eventtimeout.c index b01d8199ad..04abe71766 100644 --- a/cpukit/rtems/src/eventtimeout.c +++ b/cpukit/rtems/src/eventtimeout.c @@ -1,7 +1,7 @@ /* * Event Manager * - * COPYRIGHT (c) 1989-2007. + * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -64,25 +64,26 @@ void _Event_Timeout( * a timeout is not allowed to occur. */ + _ISR_Disable( level ); - if ( the_thread->Wait.count ) { /* verify thread is waiting */ + if ( !the_thread->Wait.count ) { /* verify thread is waiting */ + _Thread_Unnest_dispatch(); + _ISR_Enable( level ); + return; + } + the_thread->Wait.count = 0; - if ( _Event_Sync_state != EVENT_SYNC_SYNCHRONIZED && - _Thread_Is_executing( the_thread ) ) { - if ( _Event_Sync_state != EVENT_SYNC_SATISFIED ) { - _Event_Sync_state = EVENT_SYNC_TIMEOUT; + if ( _Thread_Is_executing( the_thread ) ) { + Thread_blocking_operation_States sync = _Event_Sync_state; + if ( (sync == THREAD_BLOCKING_OPERATION_SYNCHRONIZED) || + (sync == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ) { + _Event_Sync_state = THREAD_BLOCKING_OPERATION_TIMEOUT; } - _ISR_Enable( level ); - } else { - the_thread->Wait.return_code = RTEMS_TIMEOUT; - _ISR_Enable( level ); - _Thread_Unblock( the_thread ); } - } - else { - _ISR_Enable( level ); - } + the_thread->Wait.return_code = RTEMS_TIMEOUT; + _ISR_Enable( level ); + _Thread_Unblock( the_thread ); _Thread_Unnest_dispatch(); break; -- cgit v1.2.3