Is it really safe to use Java for real-time purposes?

875 Views Asked by At

I recently read the paper "Making Android run on time", by Yin Yan et al. To fully understand the topic, I also read something about the Real-Time Specification for Java (RTSJ) and about lots of real-time virtual machines, garbage collectors and so on. Nevertheless, I still have a doubt. A RTSJ-compliant virtual machine uses priority inheritance for preventing priority inversion, but I know this algorithm does not prevent deadlocks. Since threads have no way to control the resource acquisition order, there is the possibility to circular wait, that actually can lead to a deadlock.

So, in the light of this, is it really safe to use Java as a programming language for real-time purposes, included desktop and mobile applications?

My question isn't about the use of either Java, Android or Linux as-is. My question is about the algorithm choosen by the RTSJ (priority inheritance), as it doesn't prevent deadlocks to occur.

1

There are 1 best solutions below

3
On

What do you want- realtime, or desktop/mobile? Realtime is for things like a pacemaker- it means that if the computer can't promise a job will finish by time X, it won't even attempt to run it. Its only suitable for systems where the execution time of all tasks is known. Computers (including PCs, Macs, and Linux) are not realtime. As Linux is not realtime, nothing on Android is.

As for realtime Java in general- no. Nothing that has non-deterministic garbage collection can be used for realtime programming.