Thread-Safe Programming
Abstract
The thread-safety issue for function calls is discussed: under what conditions does a library function provide the correct, expected service when asynchronously called by several threads? Random number generators are used as examples of functions that are not thread safe. The thread-specific storage tools proposed by different programming environments (OpenMP, TBB, C++11, Windows) are discussed. They enforce thread safety in functions that are not by nature thread safe. Best practices concerning the thread specific storage tools are reviewed at the end of the chapter.
Keywords
Thread safety
Thread local storage
4.1 Introduction
We learned in Chapter 2 that it is perfectly legitimate to have several ...
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.