Steven W McDougall wrote:
> 
>         Thread1         Thread2
>         $a = $b;        $b = $a;
> 
> preemptive threading requires
> - mutexes to protect $a and $b
> - a robust deadlock avoidance strategy


I think a robust deadl. avd. strat. is something like:


1: make a list of all variables referenced w/in expression

2: obtain global mutex-setting sceptre (block for this)

3: block until allowed to set mutexes on entire list in 1

4: release sceptre

5: run expression

6: release all mutexes when leaving it for
any reason (and redoing 2 through 4 on reentry)


Does that not take care of

        sub setb {$b = $a};

        $a += setb() called in two threads at the same time?


The problem is, as long as expressions can be within each other,
and include terms that are multiple expressions, a robust deadlock
avoidance strategy is required even with cooperative threading.

Or you can just pass the buck to the programmer, and make them use
explict mutexes and deadlocks while they learn.


-- 
                          David Nicol 816.235.1187 [EMAIL PROTECTED]
                       safety first: Republicans for Nader in 2000

Reply via email to