3 ms·
The goal of STM is to be composable, unlike locks: http://research.microsoft.com/en-us/um/people/simonpj/papers/stm/stm.pdf http://research.microsoft.com/en-us
by jrockway 15y ago
The goal of STM is to be composable, unlike locks:
http://research.microsoft.com/en-us/um/people/simonpj/papers/stm/stm.pdf http://research.microsoft.com/en-us/um/people/simonpj/papers...
The title of the paper is "Compsable Memory Transactions", and here's an excerpt:
As we show, STM can be expressed particularly elegantly in a declarative language, and we are able to use Haskell’s type system to give far stronger guarantees than are conventionally possible. Furthermore transactions are compositional: small transactions can be glued together to form larger transactions.
- rbranson 15y agoSure, just as you'd understand a library or function to be "thread safe" it could be considered "transactional." I'm saying STM is to be used in as fine a grain as possible, even if it's composing "larger grains." Just as thread-safety doesn't mean entering a shared, global critical section at the beginning of every function, STM doesn't mean that every block of code should be wrapped in a transaction. STM should really only be applied to writes that would cause the system to be in an improper state if partially applied.
- jrockway 15y agoI'm not sure I agree. Reads also need to be in transactions in order to prevent deadlocks. I think the paper I linked is pretty accessible, so it's worth a read. I agree that most of your program should be pure, though, but that's just a good practice in general, not something tied to transactional memory.