Re: Are Perl6 threads preemptive or cooperative?
[email protected] (Chaim Frenkel) 26 Aug 2000 23:56:23 -0400
| Newsgroups | perl.perl6.language.flow |
|---|---|
| Message-ID | <[email protected]> |
A couple of other scenerios Thread 1 Thread 2 push(@a, @b); $a[35]++ User level cross variable consistancy. push(@a, $b); $acount++ if $b <35; Even cooperative threading doesn't help. <chaim> >>>>> "SWM" == Steven W McDougall <[email protected]> writes: SWM> Others have pointed out that code inside sub-expressions and blocks SWM> could also assign to our variables. This is true, but it isn't our SWM> problem. As long as each assignment is carried out correctly by the SWM> interpreter, then each variable always has a valid value, computed SWM> from other valid values. For example, SWM> $a = "abcd"; SWM> $b = "wxyz"; SWM> Thread A Thread B SWM> $a = $b; $b = $a; SWM> All the interpreter guarantees is SWM> 1. It won't crash. SWM> 2. After both threads run, $a and $b are both either "abcd" or "wxyz", SWM> (and not, for example, "abyz"). SWM> If the user cares whether the final values of $a and $b are "abcd" or SWM> "wxyz", then they have to do their own synchronization. -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183