From: george anzinger <george@mvista.com>
To: Hossein Mobahi <hmobahi@yahoo.com>
Cc: linux-c-programming@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Race: SignalHandler() & sleep()
Date: Tue, 04 Jun 2002 15:24:57 -0700 [thread overview]
Message-ID: <3CFD3E39.6FB262A2@mvista.com> (raw)
In-Reply-To: 20020604144804.33629.qmail@web12706.mail.yahoo.com
Hossein Mobahi wrote:
>
> Hello
>
> main()
> {
> ....
> signal (SIGIO, signalhandler() ) ;
> ....
> sleep (65535) ;
> ....
> }
>
> signalhandler() { ... }
>
> Assume the frequency of IO events is faster than one
> event per 65535 seconds. Therefore, let's consider
> 65535 as infinity (sleeping foreveR).
> If a SIGIO arrives, main will get out of sleep and
> continue running, but signalhandler will be invoked
> too. I wanted to know if there is any order/priority
> for sleep() in main, and signalhandler() to be called
> first, or one of them is invoked first randomly (race
> condition) ?
>
> I myself ran the program many times and everytime
> observed signalhandler responding first. But maybe it
> is not a rule, and it was just my chance ?
>
In linux (and most (all) unices) pending signals are checked
for on exit from the kernel so the order of operation is:
wake up (end of sleep) still in kernel
on exit from kernel, find signal, and deliver it, i.e. call
handler if there is one
on return from the handler, continue with the exit from the
system.
--
George Anzinger george@mvista.com
High-res-timers:
http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml
prev parent reply other threads:[~2002-06-04 22:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-04 14:48 Race: SignalHandler() & sleep() Hossein Mobahi
2002-06-04 22:24 ` george anzinger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3CFD3E39.6FB262A2@mvista.com \
--to=george@mvista.com \
--cc=hmobahi@yahoo.com \
--cc=linux-c-programming@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).