Changeset a8cd94a in rtems


Ignore:
Timestamp:
Dec 1, 1995, 7:28:58 PM (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
3837215d
Parents:
7f6fab6
Message:

Replaced critical section algorithm to correct race conditions.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/rtems/src/event.c

    r7f6fab6 ra8cd94a  
    171171  }
    172172
    173   _Event_Sync = TRUE;
     173  _Event_Sync       = TRUE;
     174  _Event_Sync_state = EVENT_SYNC_NOTHING_HAPPENED;
     175
    174176  executing->Wait.option            = (unsigned32) option_set;
    175177  executing->Wait.count             = (unsigned32) event_in;
     
    177179
    178180  _ISR_Enable( level );
    179   _Thread_Set_state( executing, STATES_WAITING_FOR_EVENT );
    180181
    181182  if ( ticks ) {
     
    189190      &executing->Timer,
    190191      ticks,
    191       WATCHDOG_NO_ACTIVATE
     192      WATCHDOG_ACTIVATE_NOW
    192193    );
    193194  }
     195
     196  _Thread_Set_state( executing, STATES_WAITING_FOR_EVENT );
    194197
    195198  _ISR_Disable( level );
    196199  if ( _Event_Sync == TRUE ) {
    197200    _Event_Sync = FALSE;
    198     if ( ticks )
    199       _Watchdog_Activate( &executing->Timer );
    200201    _ISR_Enable( level );
    201202    return;
    202203  }
     204  if ( _Event_Sync_state == EVENT_SYNC_TIMEOUT )
     205    executing->Wait.return_code = RTEMS_TIMEOUT;
    203206  _ISR_Enable( level );
    204   (void) _Watchdog_Remove( &executing->Timer );
     207  if ( ticks )
     208    (void) _Watchdog_Remove( &executing->Timer );
    205209  _Thread_Unblock( executing );
    206210  return;
     
    267271      }
    268272    }
    269     else if ( _Thread_Is_executing( the_thread ) && _Event_Sync == TRUE ) {
     273    else if ( _Event_Sync == TRUE && _Thread_Is_executing( the_thread ) ) {
    270274      if ( seized_events == event_condition || _Options_Is_any( option_set ) ) {
    271275        api->pending_events = _Event_sets_Clear( pending_events,seized_events );
    272276        *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
    273         _Event_Sync = FALSE;
     277        _Event_Sync_state = EVENT_SYNC_SATISFIED;
    274278      }
    275279    }
     
    305309      break;
    306310    case OBJECTS_LOCAL:
    307       the_thread->Wait.return_code = RTEMS_TIMEOUT;
    308       _Thread_Unblock( the_thread );
     311      if ( _Event_Sync == TRUE && _Thread_Is_executing( the_thread ) ) {
     312        if ( _Event_Sync_state != EVENT_SYNC_SATISFIED )
     313          _Event_Sync_state = EVENT_SYNC_TIMEOUT;
     314      } else {
     315        the_thread->Wait.return_code = RTEMS_TIMEOUT;
     316        _Thread_Unblock( the_thread );
     317      }
    309318      _Thread_Unnest_dispatch();
    310319      break;
  • cpukit/rtems/src/event.c

    r7f6fab6 ra8cd94a  
    171171  }
    172172
    173   _Event_Sync = TRUE;
     173  _Event_Sync       = TRUE;
     174  _Event_Sync_state = EVENT_SYNC_NOTHING_HAPPENED;
     175
    174176  executing->Wait.option            = (unsigned32) option_set;
    175177  executing->Wait.count             = (unsigned32) event_in;
     
    177179
    178180  _ISR_Enable( level );
    179   _Thread_Set_state( executing, STATES_WAITING_FOR_EVENT );
    180181
    181182  if ( ticks ) {
     
    189190      &executing->Timer,
    190191      ticks,
    191       WATCHDOG_NO_ACTIVATE
     192      WATCHDOG_ACTIVATE_NOW
    192193    );
    193194  }
     195
     196  _Thread_Set_state( executing, STATES_WAITING_FOR_EVENT );
    194197
    195198  _ISR_Disable( level );
    196199  if ( _Event_Sync == TRUE ) {
    197200    _Event_Sync = FALSE;
    198     if ( ticks )
    199       _Watchdog_Activate( &executing->Timer );
    200201    _ISR_Enable( level );
    201202    return;
    202203  }
     204  if ( _Event_Sync_state == EVENT_SYNC_TIMEOUT )
     205    executing->Wait.return_code = RTEMS_TIMEOUT;
    203206  _ISR_Enable( level );
    204   (void) _Watchdog_Remove( &executing->Timer );
     207  if ( ticks )
     208    (void) _Watchdog_Remove( &executing->Timer );
    205209  _Thread_Unblock( executing );
    206210  return;
     
    267271      }
    268272    }
    269     else if ( _Thread_Is_executing( the_thread ) && _Event_Sync == TRUE ) {
     273    else if ( _Event_Sync == TRUE && _Thread_Is_executing( the_thread ) ) {
    270274      if ( seized_events == event_condition || _Options_Is_any( option_set ) ) {
    271275        api->pending_events = _Event_sets_Clear( pending_events,seized_events );
    272276        *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
    273         _Event_Sync = FALSE;
     277        _Event_Sync_state = EVENT_SYNC_SATISFIED;
    274278      }
    275279    }
     
    305309      break;
    306310    case OBJECTS_LOCAL:
    307       the_thread->Wait.return_code = RTEMS_TIMEOUT;
    308       _Thread_Unblock( the_thread );
     311      if ( _Event_Sync == TRUE && _Thread_Is_executing( the_thread ) ) {
     312        if ( _Event_Sync_state != EVENT_SYNC_SATISFIED )
     313          _Event_Sync_state = EVENT_SYNC_TIMEOUT;
     314      } else {
     315        the_thread->Wait.return_code = RTEMS_TIMEOUT;
     316        _Thread_Unblock( the_thread );
     317      }
    309318      _Thread_Unnest_dispatch();
    310319      break;
Note: See TracChangeset for help on using the changeset viewer.