<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div id="yiv91446288"><div><div style="color:#000;background-color:#fff;font-family:times new roman, new york, times, serif;font-size:12pt;"><div id="yiv91446288"><div id="yiv91446288yui_3_2_0_17_133374823644071"><div id="yiv91446288yui_3_2_0_17_133374823644072" class="yiv91446288yui_3_2_0_17_133374823644048" style="color:#000;background-color:#fff;font-family:times new roman, new york, times, serif;font-size:12pt;"><div id="yiv91446288"><div id="yiv91446288yui_3_2_0_15_133367912126569"><div id="yiv91446288yui_3_2_0_15_133367912126570" class="yiv91446288yui_3_2_0_15_133367912126548 yiv91446288yui_3_2_0_17_133374823644050" style="color:#000;background-color:#fff;font-family:times new roman, new york, times, serif;font-size:12pt;"><div id="yiv91446288yui_3_2_0_17_133365045579348"><span
id="yiv91446288yui_3_2_0_17_133365045579381">Hi Armin:<br></span><span></span><span></span><span></span></div> <div class="yiv91446288yui_3_2_0_17_133365045579354 yiv91446288yui_3_2_0_15_133367912126550
yiv91446288yui_3_2_0_17_133374823644052" id="yiv91446288yui_3_2_0_17_133365045579356" style="font-family:times new roman, new york, times, serif;font-size:12pt;"> <div id="yiv91446288yui_3_2_0_17_133365045579388" class="yiv91446288yui_3_2_0_17_133365045579361 yiv91446288yui_3_2_0_15_133367912126552 yiv91446288yui_3_2_0_17_133374823644054" style="font-family:times new roman, new york, times, serif;font-size:12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Armin Rigo <arigo@tunes.org><br> <b><span style="font-weight:bold;">To:</span></b> Andrew Francis <andrewfr_ice@yahoo.com> <br><b><span style="font-weight:bold;">Cc:</span></b> PyPy Developer Mailing List <pypy-dev@python.org>;
"stackless@stackless.com" <stackless@stackless.com> <br> <b><span style="font-weight:bold;">Sent:</span></b> Sunday, April 1, 2012 5:23 AM<br> <b><span style="font-weight:bold;">Subject:</span></b> Re: The Work Plan Re: [pypy-dev] STM proposal funding<br> </font> </div> <br>>I'm also thinking about writing a short paper collecting things I said<br>>and think on various blog posts. A kind of "position paper". What do<br>>others think of this idea?<br><br>I think this is a great idea.<br><br>>This is not discussed a lot right now. But it is apparently<br>>relatively easy to adapt the epoll-based Twisted reactor to use the<br>>'transaction' module. (Again, this module is present in the stm-gc<br>>branch; look for lib_pypy/transaction.py for the interface, and<br>>pypy/module/transaction/* for the Python implementation on top of STM<br>>as exposed by RPython.) In addition, each transaction can add
more transactions that will be<br>>run after it. So if you want to play with lib_pypy/stackless.py to<br>>add calls to 'transaction', feel free :-) Maybe it will show that a<br>>slightly different API is required from the 'transaction' module; I<br>>don't really know so far.<br><br>Yes I can see transaction.add() being a wrapper/decorator for tasklet creation. However I think <br>that is the easy part. I'm trying to reason about the behaviour.<br><br>Starting with a simple Stackless programme:<br><br>1) All tasklets run on top of a single OS thread.<br>2) Tasklets do not yield until they are ready to commit, that is they do not call schedule() or block<br>on a channel .<br>3) Tasklets do not share state/ or variables are immutable ( because of #1 and #2, this isn't important)<br><br>This is a natural transaction<br><br>A more complicated but somewhat contrived scenario: <br><br>1) tasklets are still running over a single OS
thread <br>2) tasklets yield<br>3) tasklets share state<br><br>def transactionA(account1,
account2):<br> account1.fromAccount -= 50<br> if someRandomFunction():<br> schedule()<br> account2.toAccount += 50<br> <br>def transactionB(account1, account2):<br> t = arg.fromAccount * .1<br> account1.fromAccount -= t<br> if someRandomFunction():<br> schedule()<br> account2.toAccount += t<br><br>since the tasklets yield, this opens the door for race conditions. I need to look at how the underlying rstm module works to see how easy it would be detect conflicts amongst tasklets.<br><br>another scenario:<br><br>def transferTasklet(ch)<br> ....<br> while someFlag:<br> toAcount, fromAccount, amount =
ch.receive()<br> # transaction start<br> fromAccount.withdraw(amount)<br> toAccount.deposit(amount)<br> #transaction end<br><br>Question: without specific transaction_start() and transaction_commit() calls, how does rstm know what the start and finish of transactions are?<br><br>Cheers,<br>Andrew<br><br> </div> </div> </div></div></div></div></div></div></div></div></div></div></body></html>