Maybe someone has some experience with "realtime" operation of JNI threads?
I have a java app, which calls some C++ code for real time actions. This C++ code creates an independant pthread to do its work, which should run every 20ms.
To do this, it does its business, then calculates how long to sleep for until the next 20ms boundry (sleeping using usleep()). Now, generally this works very nicely, except that 'sometimes' my usleep waits for much longer than I asked for (eg; 120ms instead of 13ms etc). I know this because I instrumented my code to check the delay around usleep compared to the delay I asked for....
This thread is NOT the jni thread, its created with pthread_create(). I have tried:
- creating it using the SCHED_RR real time scheduler (and running as root)
- setting its priority to 99 (the max)
I thought it might be the GC in the JVM, I set lots of GC options to reduce the delays from this, but with -verbose:gc, I see no GC delays > 10ms.... (and the C++ thread doesn't interact with the JVM during its run in the test).
I have tried a thread dump (to check the priority of my thread) but kill -3 just gets me the java threads, not the JNI or pthread ones?
So:
- anyone got an idea what could be causing usleep to extend its return?
- how to dump all the threads including JNI/pthread ones in the JVM process?
cheers!
Brian