Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JNI and NSSelector



Chris's post indicated that the kernel clock
might not jump. Correct me if I'm wrong on this, but wouldn't the
kernel clock get reset on restart? I definitely want to be able to
continue timing across boots.

To continue timing across restarts, you'll need a persistent timestamp
somewhere, such as a file in the file-system (or NVRAM). All you need is a
correlation between the current GMT time and current kernel time (microsecs
since boot). In other words, GMT time of X can always be correlated to
microseconds-since-boot of Y. The persistent timestamp need only store the
GMT time. Then at any future point you correlate the current
microseconds-since-boot to a corresponding current GMT time and perform
some simple arithmetic.

This is what currentTimeMillis() does internally (in a thread-safe manner, I would note), so there you go ...

If the kernel clock does jump, then it's moot.

Not sure what you mean by kernel clock.

As long as you're worrying about time across restarts, remember to consider
what happens if the user sets the system time, either manually or via a
network time server. You'll get time-jumps then, too, possibly even a
backwards jump.

Yes, you will (if they change it backwards).

Aside: What Java needs is a non-GMT microsecond/nanosecond-level timer that does not have to correlate with GMT.

Cheers,

Andy Belk
Holistic Software Detective, Java, Apple Computer, Inc.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: JNI and NSSelector (From: Greg Guerin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.