Chapter 5

Concurrent Access to Shared Data

Abstract

Mutual exclusion is a basic synchronization primitive used to ensure thread safety when accessing shared variables. The mutual exclusion programming interfaces available in the five programming environments are reviewed, underlining the common basic features and the different additional features proposed by each one of them. Then, atomic operations are introduced as an efficient alternative to mutual exclusion in some specific cases, and the way they operate in OpenMP is reviewed. Finally, some utilities proposed by Threading Building Blocks (TBB)—basically, extensions of the Standard Template Library containers having internally built in thread safety—are introduced. A few observations concerning ...

Get Shared Memory Application Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.