Hi, Leonid, > Now, in X10, it is not a good idea to just translate the > synchronized methods to atomic blocks, because then only one object > can be updated at a time (assuming all my objects live in the same place).
Indeed, in case of large atomic blocks (like coarse-grained synchronized blocks in java), the probability of contention is high independently of how 'atomic' is implemented. (Currently atomic blocks are implemented using global lock, but STM implementation is also possible) > So, to solve this problem should I do something like this: > ... > 1. Is the example above the correct way to do it? Is there any other way? You may also check out Monitor and other classes from x10.util.concurrent: http://dist.codehaus.org/x10/xdoc/2.2.1/x10/util/concurrent/package-summary.html > 2. Looks like this approach may cause a classical deadlock, if in > one method it checks for "busy1" and then "busy2", and in the other > method "busy2" and then "busy1". This means that X10 promise of no > deadlocks is not quite true. The essence of deadlock freedom promise of X10 is that if you follow some syntactic discipline and use only some subset of the X10 language, then your program is guaranteed to be deadlock free. As far as I know, neither conditional atomic blocks, nor synchronization objects from x10.util.concurrent are included in that subset. In the general case X10 is not deadlock-free. I have just checked the X10 specification v2.2, in has a section 15.2 "Deadlock freedom" and it does not mention anything besides condition on using clocks, In other place, in section 14.7.1 "Unconditional atomic blocks", there is a statement that atomic blocks do not introduce deadlocks, which seems to apply only to unconditional atomic blocks. Maybe X10 specification needs to be clarified on the subject of deadlock freedom. ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users