From: Andi Kleen <ak@suse.de>
To: Anton Altaparmakov <aia21@cam.ac.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Q: process concurrency and sigaction()
Date: Mon, 9 Apr 2001 13:45:50 +0200 [thread overview]
Message-ID: <20010409134550.A26660@gruyere.muc.suse.de> (raw)
In-Reply-To: <5.0.2.1.2.20010409115354.00a311a0@pop.cus.cam.ac.uk>
In-Reply-To: <5.0.2.1.2.20010409115354.00a311a0@pop.cus.cam.ac.uk>; from aia21@cam.ac.uk on Mon, Apr 09, 2001 at 12:32:02PM +0100
On Mon, Apr 09, 2001 at 12:32:02PM +0100, Anton Altaparmakov wrote:
> 1. On SMP, is it guaranteed that only one (handler vs. normal program code)
> executes at the same time? (Or is it possible, for example, that signal
> handler runs on CPU1 while the normal program code is executing on CPU2?)
It's not possible (as long as you don't use multiple threads at least)
>
> 2. Is it guaranteed that execution of the normal program code is only
> resumed when the handler "return"s? (Or is it possible, for example, that
> while the handler is running, a reschedule occurs in such a way as that
> normal program code is executed before a subsequent reschedule continues
> with the handler code?)
It's is guaranteed. A signal handler is really like a private interrupt,
not a special thread.
> If this is correct, the program (non-handler) code can assume for sure that
> it will never encounter any of the locks held as the handler will have
> finished and unlocked them before execution is returned.
Yes.
>
> This would mean 1) I can grab locks in normal program code knowing that
> they will succeed immediately and 2) the signal handler doesn't need to do
> any locking at all. Just need to check if lock is held and if it is return
> immediately as it is impossible that the lock is unlocked while we are in
> the handler or that any code executes which would necessitate the lock to
> be held. - This would mean I can use a simple spinlock and use spin_lock()
> and spin_unlock() in the normal code and just a spin_is_locked() test in
> the handler. Anyone can see anything wrong with this? (Apart from the usual
It's ok, but you don't really need to spin. A flag is enough. Also you
could use the signal blocking function (sigprocmask), but they're slightly
more expensive than just setting a flag.
-Andi
next prev parent reply other threads:[~2001-04-09 11:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-09 11:32 Anton Altaparmakov
2001-04-09 11:45 ` Andi Kleen [this message]
2001-04-09 12:34 ` Anton Altaparmakov
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=20010409134550.A26660@gruyere.muc.suse.de \
--to=ak@suse.de \
--cc=aia21@cam.ac.uk \
--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
all inboxes | Powered by JetHome®