Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good multithreading guides? [closed]

I'm looking for a good guide/tutorial on multithreading in C++ (and ideally in general). Can anyone point me to a good online resource?

EDIT: I intend to familiarize myself with either the boost threading library or the one from Poco.

like image 638
StackedCrooked Avatar asked Sep 04 '09 22:09

StackedCrooked


People also ask

What is the difference between multithreading and concurrency?

Unit of Concurrency Multitasking - Multiple tasks/processes running concurrently on a single CPU. The operating system executes these tasks by switching between them very frequently. The unit of concurrency, in this case, is a Process. Multithreading - Multiple parts of the same program running concurrently.

What is multithreading enhancement?

Multithreading means that you have multiple threads of execution inside the same application. A thread is like a separate CPU executing your application. Thus, a multithreaded application is like an application that has multiple CPUs executing different parts of the code at the same time.


6 Answers

The Dr. Dobbs article "The Boost.Threads Library" is a short introduction to the subject, using one of the Boost C++ Libraries.

like image 72
Peter Mortensen Avatar answered Oct 22 '22 00:10

Peter Mortensen


That's not a tutorial, but a good set of articles Effective Concurrency by Herb Sutter.

like image 25
Kirill V. Lyadvinsky Avatar answered Oct 22 '22 02:10

Kirill V. Lyadvinsky


Take a look at Concurrent Programming on Windows by Joe Duffy. The book is relative new (November 2008) and covers theory and practice ranging topics from the Win32 API to .NET Framework 3.5.

Concurrent Programming on Windows
(source: barnesandnoble.com)

like image 32
Michael Damatov Avatar answered Oct 22 '22 01:10

Michael Damatov


If you mean to parallelize computation for multi-core, check out OpenMP. It has gcc and intel (I'm not sure about Visual C++) support, and is a lot easier than using primitives.

like image 42
Jonathan Graehl Avatar answered Oct 22 '22 02:10

Jonathan Graehl


Check out this useful video-lectures from Intel: http://software.intel.com/en-us/videos/three-things-you-must-teach-module-1-recognizing-potential-parallelism/

This tutorial covers:

  • Importance of parallelism
  • Shared memory model and threads
  • OpenMP basics

The video tutorial is very short: about 60 minutes, so I hope you will find it useful.

like image 45
Vladimir Obrizan Avatar answered Oct 22 '22 00:10

Vladimir Obrizan


If you're going to use boost::thread, I'd make sure to check out Anthony Williams' website, blogs and articles he maintains boost::thread contributed to the C++0x library particularly the threading components and the information he provides is accurate, relevant and concise.

He also has a book coming out this fall on modern C++ threading called Concurrency in Action.

Joe Duffy's book and blog is also a good resource.

like image 43
Rick Avatar answered Oct 22 '22 01:10

Rick