简体   繁体   中英

What are some ways to do multi-core programming on Android, not just multi-thread?

在Android上进行多核编程的方法有哪些,是Async-Tasks和线程本身使用了多个核还是我们需要调用某些API来实现这一点?

You don't need to use any API. The operating system and the Dalvik virtual machine schedule the execution of the threads on the available cores.

I like this blog post on the qualcomm dev site, since qualcomm is deep into the hardware cores side of things for Android: https://developer.qualcomm.com/blog/multi-threading-android-apps-multi-core-processors-part-1-2 and https://developer.qualcomm.com/blog/multi-threading-android-apps-multi-core-processors-part-2-2

TL;DR - No API's necessary, just do clean parallelization using different Android constructs available like AsyncTasks, Java Threads and IntentService and Dalvik-Linux Kernel will do the rest. Some good parts of it relevant here:

Can my single-threaded application benefit from multiple cores? How?

Even a single-threaded application can benefit from parallel processing on different cores. For example, if your application uses a media server, then the media processing and your UI rendering application logic can run on different cores at the same time. Also, the garbage collector can run on a different core.

How can I write code that takes advantage of multiple cores?

To realize the maximum potential of the available processing power on multi-core devices, write your application with concurrency in mind. The application should be designed so that tasks which can be executed in parallel are set up to run on separate threads.

Also the answers here: does single thread application utilize multi core in android? especially the one analysing perf wrt how sinngle threaded applications can utilize multicores.

I also like this from AT&T going into the specifics of Multi Core Coding in Dalvik itself. They use a Mandelbrot set image to explain which is cool with backlinks to Android dev site for multithreading.

Use multithreading to use multi cores because the android operating system and Dalvik vertual machine (DVM) manage multitasking and use multicores when in need so you do not have to use any Api . To know more about them download this pdf .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM