>>>>> "NI" == Nick Ing-Simmons <[EMAIL PROTECTED]> writes:
NI> The snag with attempting to automate such things is illustrated by :
NI> thread A thread B
NI> $a = $a + $b++; $b = $b + $a++;
NI> So we need to 'lock' both $a and $b both sides.
NI> So thread A will attempt to acquire locks on $a,$b (say)
NI> and (in this case by symetry but perhaps just by bad luck) thread B will
NI> go for locks on $b,$a - opposite order. They then both get 1st lock
NI> they wanted and stall waiting for the 2nd. We are in then in
NI> a "classic" deadly embrace.
NI> So the 'dragons' that Dan alludes to are those of intuiting the locks
NI> and the sequence of the locks to acquire, deadlock detection and backoff, ...
Agreed.
But for a single 'statement', it may be possible to gather all the
objects needing a lock and then grabbing them in order (say by address).
Also the thread doesn't need to make any changes until all the locks are
available so a backoff algorithm may work.
This would keep a _single_ statment 'consistent'. But wouldn't do anything
for anything more complex.
<chaim>
--
Chaim Frenkel Nonlinear Knowledge, Inc.
[EMAIL PROTECTED] +1-718-236-0183