I’ve installed Ubuntu 12.04 in a chroot environment on my HTC One X (QuadCore actually PentaCore) from here (v2 full): http://linuxonandroid.blogspot.de/p/downloads.html
When I start a simple Java terminal application on Ubuntu and print out the processor count using Runtime.getRuntime().availableProcessors() I’ve noticed that I get inconsistent results. It returns anywhere between 1 and 4 cores, instead of always seeing all 4.
I know that the native Android kernel uses the 4 cores on demand, but when I run the process viewer htop on Ubuntu I always see 4 CPUs! Why is Ubuntu’s JVM reporting a varying number of cores, while htop and the Ubuntu kernel can see all 4 consistently?
As far as I know, that’s just the way the JVM works. The documentation for
availableProcessors()notes (emphasis mine):My assumption would be that the fluctuations occur as the OS determines how it needs to allocate cores based on the number of processes currently running and their load on the system. Although it may not always give the JVM all four cores, it sounds like Ubuntu and Android are both working as they should be. I don’t think this is actually related to the fact that Ubuntu is running in an Android environment.