B
bob smith
Is there a way for me to look at the code for native functions such as this?
public static native long nanoTime();
Thanks.
public static native long nanoTime();
Thanks.
I believe some JREs are open source (such as OpenJDK), though I'm notIs there a way for me to look at the code for native functions such as this?
public static native long nanoTime();
Thanks.
Is there a way for me to look at the code for native functions such as this?
public static native long nanoTime();
Is there a way for me to look at the code for native functions such as this?
public static native long nanoTime();
See this blog entry:back in the early windows days I had a tool called VCommunications
Sourcer that would disassemble 16 bit code. Presumably there exist 32
and 64 bit analogs. I also had a program called Periscope that let me
trace 16 bit code at the assembler level. Again, there aught to exit
32 and 64 bit analogs, though it may be a lost art.
I wrote a 16 bit assembler back in 1985. It was very fiddly work
since there are so many variants on op code formats.
Your best bet is to look at http://jdk6.java.net/download.html and see
if Oracle will let you peek at the C source.
I was puzzling about System.nanotime too. (I think about the oddest
things in that state between sleeping and wakefulness). Does each CPU
core have its own nanocounter hardware? If a thread hops from core to
core, how does nanotime present a consistent value? Does it depend on
what other threads are doing or does it behave almost like true time?
When multiple threads run, on multiple cores and they each note some
external event, will they all assign it the same nanotime?
I do the same thing. I like to do deep dive, and have occasionally foundI like to understand things not with a set of mysterious and
apparently arbitrary lawyerly rules constraining behaviour, but with a
simplified implementation model, from which I can deduce behaviour. I
have not yet explored this, just mused.
Your best bet is to look at http://jdk6.java.net/download.html and see
if Oracle will let you peek at the C source.
nanoTime doesn't necessarily use the CPU nanocounter.
You'd think a common high frequency counter of standard frequency
would not be rocket science.
Shared, high frequency, low-latency access, predictable frequency. You
can't get all of them. Or even most of them.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.