site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com
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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Ken Hornstein