From 5f8d1c271bf27e4121b18acbbe758151ebed37a1 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 2 Jan 2013 18:56:38 +0100 Subject: rtems: Simplify _Event_Surrender() Check for a satisfied event condition only once. --- cpukit/rtems/src/eventsurrender.c | 42 +++++++++++++-------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'cpukit/rtems/src/eventsurrender.c') diff --git a/cpukit/rtems/src/eventsurrender.c b/cpukit/rtems/src/eventsurrender.c index 6e8dbbdbea..bfa29c425a 100644 --- a/cpukit/rtems/src/eventsurrender.c +++ b/cpukit/rtems/src/eventsurrender.c @@ -48,24 +48,19 @@ void _Event_Surrender( seized_events = _Event_sets_Get( pending_events, event_condition ); - /* - * No events were seized in this operation - */ - if ( _Event_sets_Is_empty( seized_events ) ) { - _ISR_Enable( level ); - return; - } - - /* - * If we are sending to the executing thread, then we have a critical - * section issue to deal with. The entity sending to the executing thread - * can be either the executing thread or an ISR. In case it is the - * executing thread, then the blocking operation state is not equal to - * THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED. - */ - if ( _Thread_Is_executing( the_thread ) && - *sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) { - if ( seized_events == event_condition || _Options_Is_any(option_set) ) { + if ( + !_Event_sets_Is_empty( seized_events ) + && ( seized_events == event_condition || _Options_Is_any( option_set ) ) + ) { + /* + * If we are sending to the executing thread, then we have a critical + * section issue to deal with. The entity sending to the executing thread + * can be either the executing thread or an ISR. In case it is the + * executing thread, then the blocking operation state is not equal to + * THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED. + */ + if ( _Thread_Is_executing( the_thread ) && + *sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) { event->pending_events = _Event_sets_Clear( pending_events, seized_events @@ -73,16 +68,7 @@ void _Event_Surrender( the_thread->Wait.count = 0; *(rtems_event_set *)the_thread->Wait.return_argument = seized_events; *sync_state = THREAD_BLOCKING_OPERATION_SATISFIED; - } - _ISR_Enable( level ); - return; - } - - /* - * Otherwise, this is a normal send to another thread - */ - if ( _States_Are_set( the_thread->current_state, wait_state ) ) { - if ( seized_events == event_condition || _Options_Is_any( option_set ) ) { + } else if ( _States_Are_set( the_thread->current_state, wait_state ) ) { event->pending_events = _Event_sets_Clear( pending_events, seized_events -- cgit v1.2.3