site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com do { time1 = get_time_stamp(); position = get_sound_position(); time2 = get_time_stamp(); } while((sw_time2 - sw_time1) > SOME_THRESHOLD); time = (time1 + time2) / 2; -Ed _______________________________________________ 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... On Oct 29, 2005, at 12:20 AM, Steve Checkoway wrote: Let me elaborate further on what I'm trying to do so that maybe someone will have a suggestion for how to proceed. Ideally, what happens is we are getting a current time stamp and then asking the sound hardware (or its driver) for it's position. The example that was given to me by another programmer is, "we can say 'the sound was at 33.5secs at 5:33:20pm.' " This is not an issue with multiple threads executing the code at the same time or with multiply threads reading and writing data at the same time. The issue is if we get the current time and then we are preempted before we get the time from the sound hardware, it introduces errors. Millisecond timing is of utmost importance so the errors introduced by this are potentially nontrivial. One idea is to raise the priority of the thread to realtime for the short time that this code is executing and then lower it back to its old priority. Since this is expected to happen 60 times each second (or so), will doing this cause undue strain for the scheduler that would impact performance in other ways negating any benefits gained by (hopefully) not being preempted during that short bit of time? You can't solve this problem the way you want with the available tools, but a slightly different approach should be workable. Assuming preemption events are rare (which they should be), you can detect failures instead of guaranteeing success. Something like: All you need to do is calibrate the SOME_THRESHOLD value with a timing loop at runtime. This email sent to site_archiver@lists.apple.com
participants (1)
-
Ed Wynne