What Is Transactive Memory?
Transactional memory (English: Transactional memory) is a parallel programming approach, which comes from the database management system (DBMS) transaction (Transaction) concept. There are currently two implementations of transaction memory, software-based software transaction memory (STM) and hardware-based HTM (Hardware Transactional Memory).
- use
- Transactional memory can be divided into two categories: deferred-update and direct-update according to the mechanism when updating data. The basic idea of deferred update of software transaction memory is that a thread only changes its own copy of the data. If there is no conflict with other threads, the final Commit action can be successfully completed, and the copy content is copied to the original; if it fails, then Cancel or backtrack (Abort / Rollback), just discard the copy. Direct update is a thread that temporarily monopolizes and directly updates the original data. The submission is confirmed, and only the exclusive setting needs to be released to allow other threads to access later. Direct update requires the original value of the data as a copy. If the operation cannot be completed in the end, you can For backtracking.
- According to different processing mechanisms in transaction conflicts, they can be divided into two categories: pessimistic & optimistic concurrency control. In pessimistic concurrency control, conflicts must be detected and resolved as soon as they occur. In optimistic concurrency control, conflict detection and resolution can be delayed, as long as it is done before the transaction is committed.
- Transactions also have the concept of granularity: the granularity that is most easily understood by programmers is the granularity of objects; under this granularity, any conflict decision is made within the scope of the object: even if the memory blocks modified by two transactions do not overlap As long as they are in the same object, you can determine that these two transactions conflict. The finer granularity is word granularity and byte granularity. Under these two granularities, conflict detection is finer and more conducive to improving the performance of the transactional memory system, but it will bring programmers No small hassle. [2]
- The implementation of software transaction memory includes atomic objects (Atomic objects) and conflict managers (Conflict manager). Among them, the realization of atomic objects is the most important, it is the medium for communication synchronization between various transactions. The implementation of atomic objects is further divided into sequential and transactional implementations: Among them, transactional implementations also require synchronization and recovery functions. Synchronization means that the ability to detect transaction conflicts is required, while recovery functions mean that When a transaction fails, the object is rolled back to the state before the transaction was executed. The atomic objects currently proposed are generally based on the read / write conflict mechanism: the atomic object provides two interfaces, one for the read interface and one for the write interface. A readable object can be obtained through the read interface, and You can get a writable object through the write interface. In order to detect conflicts (that is, the synchronization of multiple transactions when they are concurrent), two sets can be set up in a transaction, one is a read set and the other is a write set , which respectively records the reads and writes to be processed by the transaction. Atomic objects set. If the read set or write set of one transaction intersects with the write set of another transaction, it indicates that the two transactions conflict, and the conflict decider needs to take further decisions. [2]
- Sun Micro's Rock microprocessor will support hardware transaction memory.
- The Vega 2 microprocessor introduced by Azul Systems in 2009 supports hardware transactional memory. [3]
- Memory consistency model
- Lockless programming
- Task parallel
- Transactional boosting