80 likes | 198 Views
We should define semantics for languages , not for TM. Tim Harris (MSR Cambridge). The main argument. Threads, atomic blocks, retry, OrElse. Program. Language implementation.
E N D
We should define semantics for languages, not for TM Tim Harris (MSR Cambridge)
The main argument Threads, atomic blocks, retry, OrElse Program Language implementation We should focus on defining this programmer-visible interface, rather than the internal interface used by the language implementation StartTx, CommitTx, ReadTx, WriteTx TM Read, Write, CAS H/W
An analogy Program Garbage collected“infinite” memory Language implementation Low-level, broad, platform-specific API, no canonical def. GC H/W
How: strong semantics for race-free programs 1 2 3 4 5 Strong semantics: simple interleaved model of multi-threaded execution T Thread 4 in an atomic block Data race: concurrent accesses to the same location, at least one a write Write(x) Write(x) Race-free: no data races (under strong semantics)
Implementation 1: “classical” atomic blocks on TM Threads, atomic blocks, retry, OrElse Program Simple transformation Language implementation Lazy update, opacity,ordering guarantees... Strong TM H/W
Implementation 2: very weak TM Threads, atomic blocks, retry, OrElse • No: • Guarantee that reads see a consistent view of memory • Guarantee that reads/writes don’t “spill over” to adjacent memory • Detection of tx/non-tx conflicts • Publication/privatization safety • Yes: • Strict serializability in a tx-only workload Program Language implementation Program analyses StartTx, CommitTx, ValidateTx, ReadTx(addr)->val, WriteTx(addr, val) Isolation of tx via MMU Very weak STM GC support Sandboxing for zombies H/W
Implementation 3: lock inference Threads, atomic blocks, retry, OrElse Program Lock inference analysis Language implementation Locks Lock, unlock H/W
Define semantics for languages, not for TM • We should focus on the interface between the language and the programmer • Define it without talking about tx • Permit a range of tx and non-tx implementations • In a high-perf implementation, it is hard to cleanly separate the TM from other components • Interface is likely to be broad, platform-specific, and may appear weaker than the language constructs