3 ms·
thanks to both gpderetta and chrisseaton for their insightful replies. as i was looking for more sources of information, i stumbled upon this: http://kukuruku.c
by signa11 11y ago
thanks to both gpderetta and chrisseaton for their insightful replies. as i was looking for more sources of information, i stumbled upon this:
http://kukuruku.co/hub/cpp/transactional-memory-history-and-development http://kukuruku.co/hub/cpp/transactional-memory-history-and-...
where we see a large number of folks trying and eventually giving up on tm both in h/w and s/w implementations e.g. sun tried adding tm support to their sparc(rock)-v9 processor, but after oracle bought them, the project was shelved for “This processor had two astonishing features: it was incredibly low and consumed plenty of energy. It was so hot that they had to hang 12 inches of cooling fans so that processor wouldn’t overheat. It would have been insane to continue this project.”
to me at least, it seems that optimistic-reads with in-place pessimistic writes and automatic retries a.k.a weakly-atomic-update-in-place (raison d'être for tm) is the biggest torpedo in tm's direction.
for example, assume we have :
---x---x---x---x---x---x---x---x---x
bool owning_obj = false;
some_obj x = new some_obj();
/* txn-0 */
atomic {
owning_obj = true;
}
int z = x.some_value;
---x---x---x---x---x---x---x---x---x
/* txn-1 */
atomic {
if (!owning_obj)
x.some_value = 12314;
}
---x---x---x---x---x---x---x---x---x
ok, so now we have a problem :), specifically : although txn-1 would rollback, because the value of owning_obj is changed, but it is too late. the other thread using x (txn-0) will see a constantly changing state. who knows what will happen next.
it might be possible to have some kind of RCU semantics here, where you wait for a quiescent state to be reached, but that would be pretty complicated.
may you please provide your comments ? it is all very educational :)
- continuational 11y agoThat's not how TM is supposed to work; it should not be possible for one atomic block to observe an uncommitted write of another atomic block. It must act as if each atomic block acquires a single global lock, executes, and then releases the lock so that other atomic blocks may execute. The challenge is to emulate this without actually using a single global lock.
- signa11 11y ago> That's not how TM is supposed to work; it should not be possible for one atomic block to observe an uncommitted write of another atomic block. well, transactions need to be atomic w.r.t each other, but what about their relationship to non-transactional code ? it might appear that this is just an 'implementation' detail, but, programs can contain unprotected references to shared variables (i.e., outside transactions) without creating malignant data races. so, both transactional and non-transactional code can refer to the same data. this is where the notion of strong and weak atomicity comes from, and which is what the pseudo code was trying (probably unsuccessfully) to show.