[concurrency-interest] Volatile array and Wait

Pete Soper Pete.Soper at Sun.COM
Fri Oct 21 11:54:39 EDT 2005


Pete Soper wrote:

> By the way, compilers for older languages like C have had to deal with
> volatile too and this understanding has fed forward into Java. A
> proportion of C programmers have discovered the importance of volatile
> declarations when they encounter industrial strength optimizers. An
> extreme case of this was Encore Computer's C compiler that could do
> automatic parallelization of loops (e.g. making the outermost possible
> loop run iterations in parallel with multiple threads). The burden on
> the optimizer to not "screw up" instruction reordering like hoisting
> invariants, etc, was very high. But if the programmer misunderstood the
> need for volatile declarations the program would often fail when run in
> parallel (and of course a bug was filed against the "broken compiler").
> 

I went a bit too far with this: requiring a manual volatile decl in this
context would often be an indication that alias or other analysis had
broken down (i.e. it *was* a compiler bug). I should have stopped at
"industrial strength optimizers" as my memory of 15-20 years ago is not
so good.

-Pete


More information about the Concurrency-interest mailing list