volatile: a summary

Doug Gwyn gwyn at brl-smoke.ARPA
Fri Jun 10 08:10:33 AEST 1988


In article <796 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
>...  Now it is essential that the computation of
>random() be done at _each_ call.  Volatile beats all of the kludges I
>have seen to accomplish this.
>If some better method than a subroutine call is used for each number,
>the problem is still there, and I know of no better way than to use
>volatile.

Sorry, I didn't follow this.  "volatile" doesn't help (is not needed)
to ensure that the function really is called each time in the iteration.
It also is not needed if you implement your own in-line pseudo-random
number generation algorithm.  The only time it would help would be if
you had an addressible memory location that was really a hardware RNG
register.



More information about the Comp.lang.c mailing list