I am conducting research to validate claims of millisecond accuracy in psychological testing software. Up front, I am not a programmer, and have a student working to write code to have a signal sent to the serial or USB port of the computer in C (of C++), Java, and Flash. The idea is to test the ability of the OS to handle a 10-millisecond pulse with increasing layers. The hypothesis we are testing is that personal microcomputers are not capable of accurate millisecond timing unless extremely complex operations are built in to the software that allow one to turn off internal operations in the computer.
I hope to do this in Windows XP as well a Mac OS X. So far, we have an .EXE that allows me to measure a pulse from the serial port in Windows. This “program” asks for the length of the trial and the type of pulse (single or multiple) and appears to work as validated by an oscilloscope.
We appear to have hit some walls accessing the serial or USB port through Java and Flash. Anyone with programming experience that can explain things in non-programming terms want to chime in?
For Java, try here. I wouldn’t expect any measurable difference between the results in Java and in C/C++, as long as you’re careful not to let objects go out of scope in the former. Both are compiled languages (at buildtime in C, at runtime in Java) and so they’re both directly interpreted by the hardware. The choice of compiler within a given language would probably make more difference than the choice of language.
As for Flash…to be completely honest, I’d never even think to look for hardware support there. It’s just not meant to be used for that sort of thing. If you want to try an interpreted language, Perl’s your best bet.
If you’re aiming for wholly dependable timing — as in, your process gets called once per millisecond, every millisecond — then I’m sure you’ll find you can’t get that, no matter what precautions you take and no matter how quiet the system is. These aren’t real-time operating systems, and they don’t guarantee that they won’t hog the CPU for indefinite periods, whenever they feel like it.