synchronizing hardware with mach_wait_until()?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hi, I'm trying to synchronize a piece of hardware to the computer clock, and (after looking at the archives of this list) have arrived at the following strategy: mach_wait_until( end - poll ); while ( mach_absolute_time() < end ); (talk to the hardware) That is, wait until close to the desired time period, then start polling the clock. This works, if I set a "time constraint policy" with thread_policy_set(), and start polling perhaps 1/2 millisecond before the desired time. it appears I can start the hardware within a fraction of a microsecond of the desired computer clock time. However, every few hundred trials, an event will sneak in between the end of the polling and the command to talk to the hardware, which can delay the hardware by 50 microseconds or more. This behavior, after a few experiments, seems independent of the settings of the parameters sent to thread_policy_set(). It looks like the time constraint policy will guarantee a certain number of cycles in the specified period, but not when they will get assigned to the thread. I need very little CPU time, but I'd like the cycles precisely delivered. Is there some way I can execute a command immediately after a timer expires? Or, in principle, could one climb into the kernel and connect to an interrupt from the real-time clock? What's "the right way" to do this? Thanks, rob _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Rob Shaw