• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
synchronizing hardware with mach_wait_until()?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

synchronizing hardware with mach_wait_until()?


  • Subject: synchronizing hardware with mach_wait_until()?
  • From: Rob Shaw <email@hidden>
  • Date: Thu, 11 May 2006 15:16:45 +0200

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: How does one get the OS Product name programatically?
  • Next by Date: Darwin, Teredo & Miredo
  • Previous by thread: Re: How does one get the OS Product name programatically?
  • Next by thread: Darwin, Teredo & Miredo
  • Index(es):
    • Date
    • Thread