Multicore & Synchronization

Which describes the idea of hardware transactional memory?

  1. ACritical sections run speculatively; with no conflict with other threads they commit as a whole, and on conflict they abort and retry
  2. BAll memory reads and writes are logged to disk like bank transactions
  3. CMemory writes are forbidden and only reads are allowed
Show answer and explanation

Answer: A. Critical sections run speculatively; with no conflict with other threads they commit as a whole, and on conflict they abort and retry

In transactional memory, a critical section runs as a transaction whose writes stay tentative and invisible to others. If no other thread touched the same data, all writes commit at once at the end; on conflict, everything is rolled back and retried or the code falls back to an ordinary lock. When conflicts are rare, even coarse locks can achieve parallelism close to fine-grained locking.

  • A. Correct. It can sometimes run in parallel without taking the lock.
  • B. It has nothing to do with logging to disk.
  • C. Writes are performed too.