tags:

views:

32

answers:

3

To take advantage of multiprocessors 1. Do you need to select any specific programming language 2. Are there any design patterns 3. Can you schedule each thread on any available different processor

I am trying to understand good practices to write excellent programs which take full advantage of the available processors.

A: 
  1. Each language has varying support for multithreading.
  2. Yes, you can read about them in operating systems textbooks.
  3. It depends on your programming language and your tools. Often, it is easier to leave this decision to the operating system.

If you are just starting out with multithreading, you may want to look at some books: http://stackoverflow.com/search?q=multithreading+book.

Zian Choy
I create a process and have multiple threads for diffrent task. If this is executed on machine which is multiprocessor, will it take advantage automatically?
Alisha
It depends on your operating system, programming language, and your entire software toolchain. For example, C# running on a normal Windows PC would automatically take advantage of all the processors.
Zian Choy
How about a process created in C++ running on Windows. Please can I get reference for books which talk about programming for multiprocessors.
Alisha
A: 

Unless the problem you have to solve specifically asks for paralell computing I would choose the programming language best fit to solve my real problem.

The allocation of threads to processors is usually best left to the operating system. You can influence that allocation by using different priorities of threads.

I you use an language with runtime environment (java, .net) than you have the additional layer of threads within the runtime environment vs native threads.

To fully use the potential of multi processors, the problem you have must be a problem that lends itself to multi processing. There is no real use in a heavily multithreaded data entry form.

hth

Mario

Mario The Spoon
+1  A: 

Writing proper parallel code is hard.

I don't know of any textbooks, but I've found Herb Sutter's series on Effective Concurrency to be pretty good.

snemarch