248
As Figure 12-6 shows, we cannot guarantee the order with respect to how A and B
would be finally written to persistent memory. This happens because stores and flushes
to A and B are done between synchronization points. The case of C is different. Using
the SFENCE instruction, we can be assured that C will always go after A and B have been
flushed.
Knowing this, you can now imagine how out-of-order writes could be a problem in
a program crash. If assumptions are made with respect to the order of writes between
synchronization points, or if you forget to add synchronization points between writes
and flushes where strict order is essential (think of a “valid flag” for a variable write,
where the variable needs to be written before the flag is set to valid), you may encounter
data consistency issues. Consider the pseudocode in Listing 12-37.
Figure 12-6. Example of how asynchronous flushing works. The SFENCE
instruction ensures a synchronization point between the writes to A and B on one
side and to C on the other side
Chapter 12 Debugging persistent MeMory appliCations
Précédent

- 272/457

Suivant