mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jean Tourrilhes <jt@bougret.hpl.hp.com>
To: Linux kernel mailing list <linux-kernel@vger.kernel.org>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Jeff Garzik <jgarzik@mandrakesoft.com>
Subject: [QUESTION] How to use interruptible_sleep_on() without races ?
Date: Thu, 4 Apr 2002 18:52:32 -0800	[thread overview]
Message-ID: <20020404185232.B27209@bougret.hpl.hp.com> (raw)

	Hi,

	I've got a problem on using interruptible_sleep_on(). I hope
you will help me fix that ;-)

	I want to wait for a task to finish :
----------------------------------
	if(my_condition == TRUE)
		interruptible_sleep_on(&my_wait_queue);
----------------------------------

	Then, at some point, a timer/BH/soft-irq will do :
-------------------------------
	my_condition == FALSE;
	wake_up_interruptible(&my_wait_queue);
-------------------------------

	It seems straightforward, but it doesn't work. There is a race
condition between the test of the condition and the call to
sleep_on().
	I looked at it in every possible way, and I don't see how it
is possible to use safely interruptible_sleep_on(). And I wonder :
what's the point of having a function in the kernel if you can't use
it safely ?
	As a matter of fact, the TCP code doesn't use
interruptible_sleep_on() but use some complex code around schedule()
(and there must be a simpler and cleaner solution for such a simple
problem).

	Any comments ?

	Jean

             reply	other threads:[~2002-04-05  2:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-05  2:52 Jean Tourrilhes [this message]
2002-04-05  3:20 ` Alan Cox
2002-04-05  3:08   ` Jean Tourrilhes
2002-04-05  4:49     ` Linus Torvalds
2002-04-05  7:54       ` bert hubert
2002-04-05 12:58     ` Alan Cox
2002-04-05 20:16       ` Jean Tourrilhes

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=20020404185232.B27209@bougret.hpl.hp.com \
    --to=jt@bougret.hpl.hp.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=jgarzik@mandrakesoft.com \
    --cc=jt@hpl.hp.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®