From 18269cef34e796931cbf7d6f7b3e1a23c1830bf8 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 13 Feb 1996 15:37:33 +0000 Subject: comment added to describe synchronization logic in timeout routine --- c/src/exec/rtems/src/event.c | 21 +++++++++++++++++++++ cpukit/rtems/src/event.c | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/c/src/exec/rtems/src/event.c b/c/src/exec/rtems/src/event.c index 3042de2676..141c5411cf 100644 --- a/c/src/exec/rtems/src/event.c +++ b/c/src/exec/rtems/src/event.c @@ -198,14 +198,22 @@ void _Event_Seize( switch ( sync_state ) { case EVENT_SYNC_SYNCHRONIZED: + /* + * This cannot happen. It indicates that this routine did not + * enter the synchronization states above. + */ + return; + case EVENT_SYNC_NOTHING_HAPPENED: _ISR_Enable( level ); return; + case EVENT_SYNC_TIMEOUT: executing->Wait.return_code = RTEMS_TIMEOUT; _ISR_Enable( level ); _Thread_Unblock( executing ); return; + case EVENT_SYNC_SATISFIED: if ( _Watchdog_Is_active( &executing->Timer ) ) { _Watchdog_Deactivate( &executing->Timer ); @@ -328,6 +336,19 @@ void _Event_Timeout( case OBJECTS_REMOTE: /* impossible */ break; case OBJECTS_LOCAL: + + /* + * If the event manager is not synchronized, then it is either + * "nothing happened", "timeout", or "satisfied". If the_thread + * is the executing thread, then it is in the process of blocking + * and it is the thread which is responsible for the synchronization + * process. + * + * If it is not satisfied, then it is "nothing happened" and + * this is the "timeout" transition. After a request is satisfied, + * a timeout is not allowed to occur. + */ + if ( _Event_Sync_state != EVENT_SYNC_SYNCHRONIZED && _Thread_Is_executing( the_thread ) ) { if ( _Event_Sync_state != EVENT_SYNC_SATISFIED ) diff --git a/cpukit/rtems/src/event.c b/cpukit/rtems/src/event.c index 3042de2676..141c5411cf 100644 --- a/cpukit/rtems/src/event.c +++ b/cpukit/rtems/src/event.c @@ -198,14 +198,22 @@ void _Event_Seize( switch ( sync_state ) { case EVENT_SYNC_SYNCHRONIZED: + /* + * This cannot happen. It indicates that this routine did not + * enter the synchronization states above. + */ + return; + case EVENT_SYNC_NOTHING_HAPPENED: _ISR_Enable( level ); return; + case EVENT_SYNC_TIMEOUT: executing->Wait.return_code = RTEMS_TIMEOUT; _ISR_Enable( level ); _Thread_Unblock( executing ); return; + case EVENT_SYNC_SATISFIED: if ( _Watchdog_Is_active( &executing->Timer ) ) { _Watchdog_Deactivate( &executing->Timer ); @@ -328,6 +336,19 @@ void _Event_Timeout( case OBJECTS_REMOTE: /* impossible */ break; case OBJECTS_LOCAL: + + /* + * If the event manager is not synchronized, then it is either + * "nothing happened", "timeout", or "satisfied". If the_thread + * is the executing thread, then it is in the process of blocking + * and it is the thread which is responsible for the synchronization + * process. + * + * If it is not satisfied, then it is "nothing happened" and + * this is the "timeout" transition. After a request is satisfied, + * a timeout is not allowed to occur. + */ + if ( _Event_Sync_state != EVENT_SYNC_SYNCHRONIZED && _Thread_Is_executing( the_thread ) ) { if ( _Event_Sync_state != EVENT_SYNC_SATISFIED ) -- cgit v1.2.3