473,396 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem with "realtime" JNI C++ threads with java 1.4.2 on linux FC4

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
Oct 2 '06 #1
1 2996
r035198x
13,262 8TB
The usleep() function suspends the calling thread until either the number of real-time microseconds specified by period has elapsed or a signal is delivered to the calling thread. The suspension time may be longer than requested because the argument value is rounded up to an integer multiple of the sleep resolution, or due to the scheduling of other activity by the system.
threading and gc are platform dependant, moreso when implemented in platform dependant languages
Oct 2 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jive | last post by:
I've ported Python to a realtime operating system and embedded it in an application that controls machinery. Python will be used to expose an API to end users. It seems prudent to disable...
32
by: Christopher Benson-Manica | last post by:
Is the following code legal, moral, and advisable? #include <iostream> class A { private: int a; public: A() : a(42) {}
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
5
by: Markus S. | last post by:
Hello, I have a problem with a DOS EXE that is called by a .Net Winforms application. I need to redirect the console output into a textbox, but this should happen in real time, so when new...
9
by: aardappel | last post by:
Some of you may enjoy this style of programming: http://strlen.com/rants/javaclassesincpp.html I am aware that this post will generate a lot of complaints that this is not how one is...
4
by: malv | last post by:
How would you approach the following? In a multithreaded realtime data acquisition system (all python v2.4), after hours of running without a snag, without warning python hangs at once without...
3
by: rkhurana | last post by:
Hi I am writing a JSF application that uses some third party charts. While I can see the chart but the javascript that is supposed to calla function to update chart periodically has a problem. It...
3
by: Ludwig Wittgenstein | last post by:
Hello, all. Does anyone know of documentation about implementing a publish- subscribe model between a .NET Web service provide and a Java service consumer? I have this problem I am trying to...
6
by: rgagarrett | last post by:
Hi, I hope this is the correct group for my query, please advise if there's a more relevant place for me! I'm using a USB camera (Sentech C83) with Linux and I have some C code for reading data...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.