Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ synchronization guidelines

Does anyone know of a decent reference for synchronization issues in C++? I'm thinking of something similar to the C++ FAQ lite (and the FQA lite) but with regards to concurrency, locking, threading, performance issues, guidelines, when locks are needed and when they aren't, dealing with multithreaded library code that you can't control, etc. I don't care about the inner issues of how different lock types can be implemented etc, I just use boost for that.

I'm sure there are a lot of good books out there, I'd prefer something (preferably online) that I can use as a goto for when a question or an issue pops up in my mind. I'm not really a beginner to this all so I would like a concise reference for all those different types of situations that can popup when writing multithreaded libraries that use other multithreaded libraries.

Like:

  • When is it better to have one big lock protecting a bunch of data vs a bunch of smaller locks protecting each piece of data? (what are the costs associated with having lots of locks? Resource acquisition costs? Locking time performance costs?)

  • What's the performance hit of pushing something onto a queue and having another thread pop the queue vs dealing that that data in the original thread?

  • Are there any simple idioms to make sure things just work when you're not so concerned about performance?

Anyway, I just want to know if there are any decent references out there that people use.

like image 408
Scott Avatar asked Dec 28 '22 07:12

Scott


1 Answers

I'd recommend two resources:

  • Herb Sutter's Effective Concurrency articles
  • Anthony Williams's C++ Concurrency In Action (not yet published, but available as a PDF)
like image 180
James McNellis Avatar answered Jan 10 '23 19:01

James McNellis