On Mon, Aug 17, 2009 at 1:56 PM, Mark Volkmann <r.mark.volkm...@gmail.com>wrote:
> > Does Clojure STM eliminate the possibility of deadlock? When two > transactions have a contention for the same Ref, Clojure gives > preference to the transaction that has been running the longest > (unless it has only been running for a very short amount of time - see > bargeTimeElapsed in LockingTransaction.java). Is that alone enough to > guarantee that a deadlock over Refs cannot occur? The transaction that > has been running the longest may never finish, going into an infinite > loop. Other transactions that contend for the same Refs will continue > retrying until they hit the 10,000 retry limit and then an exception > will be thrown, so I supposed technically that isn't deadlock. I beileve the term for this is livelock. Deadlock is when thread A locks mutex M and waits for mutex N while thread B locks mutex N and waits for mutex M. I have not looked deeply into Clojure's STM implementation, but the ordered locking mentioned elsewhere in this thread should prevent deadlock. However, I don't believe it is possible to prevent the kind of livelock you describe. I definitely could be mistaken, but this is my understanding of things. Regards, - J. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---