transactional memory aims to automate the selection and acquisition of locks. whether transactional memory can be done efficiently, and adopted incrementally is still uncertain.
there are both software and hardware implementations of transactional memory. at first they seemed to me sequential evolutionary steps but that is not the case. Most HTM implementations operate at cache line granularity and use cache coherence protocols to track and maintain different copies of shared memory areas. most STMs operate at object level and use locks, temporary copies of objects, and additional data structures to keep track of transactions and mutated state. the fundamental problem of HTM is transactions that exceed cache sizes or that last longer than one scheduling quantum. the fundamental problem of STM is overhead. it seems natural to expect a balanced hybrid to offer the best of both worlds.
transactional memory implementations differ in certain key attributes. the choices often depend on whether commits or aborts are expected to be more frequent.
shared state can be modified in place or on a separate copy. in place modification requires a second copy to be created to maintain the original state in case of an abort. in place modification makes commits cheap.
concurrency can be handled optimistically - several threads can enter the same critical section concurrently. if the threads do not conflict the locking would have been overhead. if a conflict is detected all but one thread are aborted.
conflicts can be detected as soon as they occur or only at commit time. late detection saves overhead in the absense of contention. early detection involves more bookkeeping work, but when a conflict occurs it skips the useless computation in the doomed portion of the transaction. late detection can also allow computation on inconsistent state. th results will eventually be discarded but it can result in exceptions that wouldn't occur otherwise.
the semantics of nested transactions can be defined in two ways
for aborts:
- a nested transaction aborts the parent transaction.
- a nested transaction allows the parent to proceed.
- changes committed in a nested transaction become visible to the parent transaction.
- changes committed in a nested transaction become visible in global state.