Re: Use of Events in kext
Re: Use of Events in kext
- Subject: Re: Use of Events in kext
- From: Ken Hornstein <email@hidden>
- Date: Fri, 23 Sep 2011 10:45:13 -0400
>I am porting windows code to MAC. In Windows we
>haveKeWaitForMultipleObjects(), which puts the current thread to wait
>state until any or all of a number of dispatcher objects are set to a
>signaled state or (optionally) until the wait times out. My
>requirement is I need to wait for 2 events at a time until one of them
>issignaled. In mac we doesn't have events, one of the option is
>msleep, can anyone suggest any alternatives?
When you say "objects", you're talking about your own code, right?
I've written the inverse (multiple threads waiting for a signal from
one thread) as part of an emulation of the Linux "waitq" interface, but
the concepts should work fine for you. That used the Mach thread
interface. Basically, in the waiter thread you do:
res = assert_wait(addr, state);
if (res == THREAD_WAITING)
thread_block(THREAD_CONTINUE_NULL);
(If you want a timeout, you can call assert_wait_deadline() instead).
And in the wakeup threads, you do:
thread_wakeup_one(addr);
Obviously the key here is to have all of your other "dispatcher objects"
make sure they call thread_wakeup_one() on the right addr.
--Ken
_______________________________________________
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