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.
Practice this topic Back to topic

More Multicore & Synchronization questions

  1. When waiting on a condition variable until a queue becomes non-empty, why is the condition rechecked in a while loop rather than an if after waking?
  2. Two cores each hold a copy of variable x in their own caches. After core 0 writes x, what problem could occur when core 1 reads x if there were no cache coherence mechanism?
  3. Which correctly lists the four states of the MESI cache coherence protocol?
  4. In the MESI protocol, what does it mean when a cache line is in the Modified (M) state?
  5. In the MESI protocol, what happens when a core writes to a line it holds in the Exclusive (E) state?