Proposed Language Support
The conceptual simplicity of STMs enables them to be exposed to the programmer using relatively simple language syntax. Tim Harris and Keir Fraser's "Language Support for Lightweight Transactions" proposed the idea of using the classical conditional critical region (CCR) to represent transactions. In its simplest form, this is just an "atomic block", a block of code which logically occurs at a single instant:
// Insert a node into a doubly linked list atomically atomic { newNode->prev = node; newNode->next = node->next; node->next->prev = newNode; node->next = newNode; }When the end of the block is reached, the transaction is committed if possible, or else aborted and retried. CCRs also permit a guard condition, which enables a transaction to wait until it has work to do:
atomic (queueSize > 0) { remove item from queue and use it }If the condition is not satisfied, the transaction manager will wait until another transaction has made a commit that affects the condition before retrying. This loose coupling between producers and consumers enhances modularity compared to explicit signaling between threads. "Composable Memory Transactions" took this a step farther with its retry command (discussed above), which can, at any time, abort the transaction and wait until some value previously read by the transaction is modified before retrying. For example:
atomic { if (queueSize > 0) { remove item from queue and use it } else { retry } }This ability to retry dynamically late in the transaction simplifies the programming model and opens up new possibilities.
One issue is how exceptions behave when they propagate outside of transactions. In "Composable Memory Transactions", the authors decided that this should abort the transaction, since exceptions normally indicate unexpected errors in Concurrent Haskell, but that the exception could retain information allocated by and read during the transaction for diagnostic purposes. They stress that other design decisions may be reasonable in other settings.
Read more about this topic: Software Transactional Memory
Famous quotes containing the words proposed, language and/or support:
“To coƶperate in the highest as well as the lowest sense, means to get our living together. I heard it proposed lately that two young men should travel together over the world, the one without money, earning his means as he went, before the mast and behind the plow, the other carrying a bill of exchange in his pocket. It was easy to see that they could not long be companions or coƶperate, since one would not operate at all. They would part at the first interesting crisis in their adventures.”
—Henry David Thoreau (18171862)
“Had Dr. Johnson written his own life, in conformity with the opinion which he has given, that every mans life may be best written by himself; had he employed in the preservation of his own history, that clearness of narration and elegance of language in which he has embalmed so many eminent persons, the world would probably have had the most perfect example of biography that was ever exhibited.”
—James Boswell (174095)
“American feminists have generally stressed the ways in which men and women should be equal and have therefore tried to put aside differences.... Social feminists [in Europe] ... believe that men and society at large should provide systematic support to women in recognition of their dual role as mothers and workers.”
—Sylvia Ann Hewitt (20th century)