* Is there a primitive to atomically release a spinlock and go to sleep?
@ 2010-09-02 1:04 David Nicol
2010-09-02 2:16 ` Andy Lutomirski
0 siblings, 1 reply; 2+ messages in thread
From: David Nicol @ 2010-09-02 1:04 UTC (permalink / raw)
To: Linux Kernel Mailing List
I'm trying to do something involving multiple kthreads in an ioctl
handler, and I want to avoid the
race condition between the third and fourth steps of
acquire mutex
add &self to a list of threads which will get awakened by
something else that is also aware of this list
release mutex
go to sleep
Is there a standard atomic go-to-sleep function that takes as a
parameter a pointer to spinlock to release after its state is set to
TASK_INTERRUPTIBLE?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Is there a primitive to atomically release a spinlock and go to sleep?
2010-09-02 1:04 Is there a primitive to atomically release a spinlock and go to sleep? David Nicol
@ 2010-09-02 2:16 ` Andy Lutomirski
0 siblings, 0 replies; 2+ messages in thread
From: Andy Lutomirski @ 2010-09-02 2:16 UTC (permalink / raw)
To: David Nicol; +Cc: Linux Kernel Mailing List
David Nicol wrote:
> I'm trying to do something involving multiple kthreads in an ioctl
> handler, and I want to avoid the
> race condition between the third and fourth steps of
>
> acquire mutex
> add &self to a list of threads which will get awakened by
> something else that is also aware of this list
> release mutex
> go to sleep
>
> Is there a standard atomic go-to-sleep function that takes as a
> parameter a pointer to spinlock to release after its state is set to
> TASK_INTERRUPTIBLE?
That wouldn't be enough -- the other thread could try to wake you up before you're even in the list of threads.
Look at wait_event_*() or read this:
http://book.chinaunix.net/special/ebook/PrenticeHall/PrenticeHallPTRTheLinuxKernelPrimer/0131181637/ch03lev1sec7.html
--Andy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-02 2:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-02 1:04 Is there a primitive to atomically release a spinlock and go to sleep? David Nicol
2010-09-02 2:16 ` Andy Lutomirski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox