From: arighi Date: Mon, 1 Nov 2010 16:23:32 +0000 (+0000) Subject: event: always add a memory barrier before returning from event_waitTimeout() X-Git-Tag: 2.6.0~5^2~40 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=961e7ada98d6520a74818efa4731210c1375b068;hp=9cb8aabd5d89b030d527f1c8da1676ec9dbb805c;p=bertos.git event: always add a memory barrier before returning from event_waitTimeout() In this way we are sure the compiler will not perform optimizations or instruction reordering: so that the return from event is always done after the execution of the corresponding event_do(). git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4480 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/mware/event.h b/bertos/mware/event.h index 4e2aace1..b797b7eb 100644 --- a/bertos/mware/event.h +++ b/bertos/mware/event.h @@ -256,23 +256,23 @@ INLINE void event_wait(Event *e) */ INLINE bool event_waitTimeout(Event *e, ticks_t timeout) { + bool ret; + #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS e->Ev.Sig.sig_proc = proc_current(); - return (sig_waitTimeout(e->Ev.Sig.sig_bit, timeout) & SIG_TIMEOUT) ? + ret = (sig_waitTimeout(e->Ev.Sig.sig_bit, timeout) & SIG_TIMEOUT) ? false : true; #else ticks_t end = timer_clock() + timeout; - bool ret; while ((ACCESS_SAFE(e->Ev.Gen.completed) == false) || TIMER_AFTER(timer_clock(), end)) cpu_relax(); ret = e->Ev.Gen.completed; e->Ev.Gen.completed = false; +#endif MEMORY_BARRIER; - return ret; -#endif } #endif /* CONFIG_TIMER_EVENTS */