Shared Storage Pitfalls
Shared Storage Pitfalls
Shared Storage Pitfalls
When creating applications that take advantage of shared storage, you need to avoid two types of problems that can result in unpredictable data values: race conditions and storage access ordering problems.
-
A race condition exists when different program results are possible due solely to the relative timing of two or more cooperating threads.
You can avoid race conditions by synchronizing the processing of the competing threads so that they interact in a predictable, well-behaved manner. Although the focus of this document is on storage synchronization, the techniques for synchronizing thread execution and synchronizing storage overlap to a great extent. Because of this, the example problems discussed later in this topic briefly touch on race conditions.
-
Storage access ordering problems are also known as storage synchronization or memory consistency problems. These problems result when two or more cooperating threads rely on a specific ordering of updates to shared storage, and their respective accesses to the storage accesses are not synchronized. For example, one thread might store values to two shared variables, and another thread has an implicit dependency on observing those updates in a certain order.
You can avoid shared storage access ordering problems by ensuring that the system performs storage synchronization actions for the threads that read from and write to shared storage. Some of these actions are described in the following topics.