Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Software transactional memory
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Proposed language support == The conceptual simplicity of STMs enables them to be exposed to the programmer using relatively simple language [[Syntax (programming languages)|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. (This is simply a conceptual example, not correct code. For example, it behaves incorrectly if node is deleted from the list during the transaction.) 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"<ref name="cmt"/> 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",<ref name="cmt"/> 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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)