retry and monitor locks?

28 views
Skip to first unread message

Maurice Herlihy

unread,
Jan 5, 2013, 12:41:13 PM1/5/13
to scala-stm-e...@googlegroups.com
If I call retry while inside a synchronized block, will the monitor lock be released correctly?

  Maurice

Nathan Bronson

unread,
Jan 5, 2013, 1:15:30 PM1/5/13
to scala-stm-e...@googlegroups.com
Yes, it will be released. The stack is unwound with an exception, so monitors are released and finally blocks are executed. (If a finally block calls into an STM function an exception is thrown again.)

There is a potential for deadlock if you mix transactions with synchronized. ScalaSTM is just a library, so it isn't aware of scheduling contraints imposed by the monitors, and the underlying algorithm is not lock free. It is based on SwissTM, which eagerly acquires write locks. Under contention it also uses read locks.

 - Nathan

On Sat, Jan 5, 2013 at 9:41 AM, Maurice Herlihy <maurice...@gmail.com> wrote:
If I call retry while inside a synchronized block, will the monitor lock be released correctly?

  Maurice
--
Nathan Grasso Bronson
ngbr...@gmail.com
Reply all
Reply to author
Forward
0 new messages