This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes C / C++ and the fly likes  C++ Concurrency in Action book question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark " C++ Concurrency in Action book question" Watch " C++ Concurrency in Action book question" New topic
Author

C++ Concurrency in Action book question

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
How will the latest C++ concurrency standard handle issues such as deadlock, livelock, fairness, starvation, race condition?
Do the C++ Concurrency in Action book has examples for the above concurrency issues?
Anthony Aj Williams
author
Ranch Hand

Joined: Jun 10, 2011
Posts: 56
albert kao wrote:How will the latest C++ concurrency standard handle issues such as deadlock, livelock, fairness, starvation, race condition?


To a large extent these issues are all about the correctness of your code rather than anything that the library can handle. However, the library does provide one direct facility that can help: std::lock(). This is a function template that takes a set of mutexes (or wrappers such as std::unique_lock<>) and locks all of them in one go, without risk of deadlock due to lock ordering issues. This allows you to lock pairs (or triplets) of mutexes in different threads without having to worry about the order of the locks causing deadlock.

albert kao wrote:Do the C++ Concurrency in Action book has examples for the above concurrency issues?


Yes. Concurrency-related bugs are covered in chapter 10, but there are also examples given throughout the book. Chapter 3 discusses locks and deadlocks, and gives examples for std::lock() usage, as well as code for a simple hierarchical mutex class that helps avoid deadlock by enforcing lock ordering.


Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/
just::thread C++11 thread library http://www.stdthread.co.uk
Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: C++ Concurrency in Action book question
 
Similar Threads
How can we count the number of objects created per class using Java1.5 API?
Concurrency and SCEA Assignment
Questions on C++ Concurrency in Action
posix threads and performance with posix libraries
Concurrency Issue in Servlet