Re: Thread sleep
Re: Thread sleep
- Subject: Re: Thread sleep
- From: Chris Suter <email@hidden>
- Date: Fri, 11 Sep 2009 09:12:16 +1000
On Fri, Sep 11, 2009 at 6:44 AM, Eric Long <email@hidden> wrote:
> I have a kext that sends data to a daemon via an IODataQueue. The daemon
> processes the data and sends back a response to my IOUserClient.
>
> The thread that enqueues the data must have the response or time-out before
> continuing. The response obviously comes on a separate thread.
>
> Ideally, the enque thread will go to sleep and be woken up by the response
> handler. The problem is there is a window for a race condition between when
> the enque thread is actually asleep and when the response arrives and the
> handler wants to wake it up. This leaves the potential that the thread is
> not asleep and therefore not ready to be woken up.
>
> The thread primitives that might allow me to check if the thread is sleeping
> are not exposed in the kpi.
>
> Anyone with advice on how to reconcile this?
Look at IOLockSleep and IOLockWakeup. You want code like this:
IOLockLock(lock);
while (!condition)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden