1

What are some ways to do multi-core programming on Android, is it that Async-Tasks and threads they themselves used multiple cores or do we need to call some API's to enforce that?

MindBlowing
  • 11
  • 1
  • 2
  • 4
    multi-threading should automatically use multi-cores, the operating system takes care of that. You cannot enforce that yourself. – bas Aug 11 '13 at 13:07

3 Answers3

9

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.

Joni
  • 108,737
  • 14
  • 143
  • 193
1

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.

Community
  • 1
  • 1
Vrashabh Irde
  • 14,129
  • 6
  • 51
  • 103
-1

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.

Prakhar
  • 2,270
  • 19
  • 26
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Eran Aug 11 '13 at 13:28
  • thank you for your suggestion but please upvote this i have got question ban please help me.. – Prakhar Aug 11 '13 at 13:30
  • -1 for incorrect mention of DDMS, which has absolutely nothing to do with run time operation. It is a viewing tool for developers only. – Chris Stratton Aug 11 '13 at 13:43