[PATCH 5/5] rtems: Simplify _Event_Surrender()
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed Jan 2 17:56:38 UTC 2013
Check for a satisfied event condition only once.
---
cpukit/rtems/src/eventsurrender.c | 42 +++++++++++++------------------------
1 file changed, 14 insertions(+), 28 deletions(-)
diff --git a/cpukit/rtems/src/eventsurrender.c b/cpukit/rtems/src/eventsurrender.c
index 6e8dbbd..bfa29c4 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
--
1.7.10.4
More information about the devel
mailing list