http://stackoverflow.com/questions/7962155/how-can-you-detect-a-dual-core-cpu-on-an-andro id-device-from-code says that availableProcessors() can under-report the number of CPUs available on the device. http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Runtime.html#availableProcessors() also says "This value may change during a particular invocation of the virtual machine.".
>From the source, availableProcessors returns the available processors, not necessarily all the physically present CPUs. public int availableProcessors() { // See http://austingroupbugs.net/view.php?id=339. // _SC_NPROCESSORS_ONLN : The number of processors online (capable of running processes). // _SC_NPROCESSORS_CONF - The number of processors configured. return (int) Libcore.os.sysconf(_SC_NPROCESSORS_ONLN); } On Android, when will _SC_NPROCESSORS_ONLN and _SC_NPROCESSORS_CONF differ? Do any kernels restrict app code to a subset of the physically available processors (using sched_setaffinity)? What is the correct way to find the number of cpus on the device in order to determine which optimizations to enable in my app? This needs to include cpus that may currently be powered down if they will get enabled once my optimization code starts executing. Thanks, Shri -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en