From: arighi Date: Thu, 3 Jun 2010 12:18:50 +0000 (+0000) Subject: signal: correctly deliver signal to current_process. X-Git-Tag: 2.5.0~27 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=2a1c85e3ba1d419df58103d4f932f24f8e2afe1a;p=bertos.git signal: correctly deliver signal to current_process. It may happen that a process needs to send a signal to itself to synchronize on an asynchronous event, e.g., an event triggered by an interrupt. In such case we must correctly clear the proc->sig_wait mask. This fix also improves the signal delivery's performance, because we don't need to check anymore if we need to skip the delivery to current_process. NOTE: we can replace this check with an ASSERT(), if proc->sig_wait is set the current process can't actively deliver a signal to itself (it's in sleep state waiting for a signal and can't run by definition). git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3890 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/kern/signal.c b/bertos/kern/signal.c index 71ccf67a..139e69da 100644 --- a/bertos/kern/signal.c +++ b/bertos/kern/signal.c @@ -251,9 +251,6 @@ INLINE void __sig_signal(Process *proc, sigmask_t sigs, bool wakeup) { cpu_flags_t flags; - if (UNLIKELY(proc == current_process)) - return; - IRQ_SAVE_DISABLE(flags); /* Set the signals */ @@ -262,6 +259,8 @@ INLINE void __sig_signal(Process *proc, sigmask_t sigs, bool wakeup) /* Check if process needs to be awoken */ if (proc->sig_recv & proc->sig_wait) { + ASSERT(proc != current_process); + proc->sig_wait = 0; if (wakeup) proc_wakeup(proc);