All of lore.kernel.org
 help / color / mirror / Atom feed
* [QUESTION] How to use interruptible_sleep_on() without races ?
@ 2002-04-05  2:52 Jean Tourrilhes
  2002-04-05  3:20 ` Alan Cox
  0 siblings, 1 reply; 7+ messages in thread
From: Jean Tourrilhes @ 2002-04-05  2:52 UTC (permalink / raw)
  To: Linux kernel mailing list, Alan Cox, Jeff Garzik

	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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-04-05 20:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-05  2:52 [QUESTION] How to use interruptible_sleep_on() without races ? Jean Tourrilhes
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.