O'Reilly logo

Shared Memory Application Programming by Victor Alessandrini

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required