Transactional Memory Support for C [pdf]
open-std.org
open-std.org
Since the paper publication (2008), HTM support was added on a few mainstream CPUs (intel, power).
Also, TM is likely to be in the next C++ standard: the specification has been published as Technical Report (GCC already implements a slightly older draft) and handles many of the issues identified in the paper, in particular its interaction with non-transactional atomic operations and exceptions.
Mind you, TM might still end up not being worth the trouble, but at least there is a serious ongoing effort to push it into a mainstream language.
I believe that, among the authors of the paper, at least Magel Michael was involved in the C++ Transactonal Memory TR.
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---xok, 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 :)
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.
That article should be read with that context in mind.
Now that transactional memory has fallen well out of fashion and people are being a bit more realistic I think it's more likely it will be applied by experts as a kind of multi-word compare and swap, for implementing specific data structures with some support for composability. Which of course would still be a gain for software engineering.
This C++ work could support that kind of use-case.
Addendum: I don't want to imply that Troff and TeX are not adequate. Quite to the contrary. This PDF from Word is so bad that it doesn't match a quality that we surpassed decades ago. And even while using Word, the typesetting could be much better.
$ pdfinfo n1961.pdf
Author: Michael Wong
Creator: Acrobat PDFMaker 9.0 for Word
Producer: Adobe PDF Library 9.0
CreationDate: Mon Sep 28 05:04:06 2015
ModDate: Mon Sep 28 05:04:23 2015
Tagged: yes
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 9
Encrypted: no
Page size: 612 x 816.96 pts
Page rot: 0
File size: 198701 bytes
Optimized: yes
PDF version: 1.5I've seen pure text mails of mine getting copied into ".ppt" with horrible formatting an then getting send around by e-mail. And I just had some plain text-only questions nothing anybody would ever present.
I remember there was a computer architecture journal (ACM SIGARCH?) which had articles which were photocopies of dot-matrix printouts.