mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikael Pettersson <mikpe@it.uu.se>
To: "Eric Smith" <eric@brouhaha.com>
Cc: "Andi Kleen" <andi@firstfloor.org>, linux-kernel@vger.kernel.org
Subject: Re: Any lightweight way for one thread to force another thread to   suspend execution?
Date: Tue, 24 Jun 2008 09:59:24 +0200	[thread overview]
Message-ID: <18528.43356.997214.585578@harpo.it.uu.se> (raw)
In-Reply-To: <57001.64.62.206.10.1214255297.squirrel@ruckus.brouhaha.com>

Eric Smith writes:
 > Andi wrote about my inquire regarding a way to synchronously stop
 > another thread:
 > > Any such mechanism will need a syscall, and it's unlikely that
 > > any syscall will get much cheaper than a kill(SIGSTOP)
 > 
 > Unfortunately, as Bart pointed out, this stops ALL the threads
 > in a process (required for POSIX conformance).  However, it appears that
 > I may be able to do it by creating my threads using clone() with appropriate
 > parameters rather than pthread_create().
 > 
 > The next question, which I haven't yet been able to answer for myself
 > from staring at the kernel sources, is whether sending SIGSTOP is
 > synchronous.  In other words, when the kill() returns, is the target
 > thread already stopped?  Even on an SMP system where the thread may have
 > been executing concurrently on another processor?
 > 
 > If not, the next question will be whether there's a more efficient way
 > to wait for a process to enter the "T" state than busy-polling a file
 > in /proc.

SIGSTOP is unreliable since some other process may wake the
target up with a SIGCONT.

man ptrace(), see the PTRACE_ATTACH request.

(Presumably it will DTRT if you give it a tid not just a pid,
but I haven't tested that.)

  reply	other threads:[~2008-06-24  7:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-20 23:54 Eric Smith
2008-06-21 14:04 ` Andi Kleen
2008-06-22  1:55   ` Eric Smith
2008-06-22  6:33     ` Bart Van Assche
2008-06-22  9:14     ` Jan Engelhardt
2008-06-23 21:08   ` Eric Smith
2008-06-24  7:59     ` Mikael Pettersson [this message]
2008-06-21 16:38 ` Bart Van Assche
2008-06-22  2:02   ` Eric Smith

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=18528.43356.997214.585578@harpo.it.uu.se \
    --to=mikpe@it.uu.se \
    --cc=andi@firstfloor.org \
    --cc=eric@brouhaha.com \
    --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®