[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4C7F08ED.9010901@mit.edu>
Date: Wed, 01 Sep 2010 22:16:13 -0400
From: Andy Lutomirski <luto@....edu>
To: David Nicol <davidnicol@...il.com>
CC: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: Is there a primitive to atomically release a spinlock and go
to sleep?
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists