From: utzoo!decvax!harpo!seismo!rlgvax!tom Newsgroups: net.lang.c Title: RE: C and real hardware Article-I.D.: rlgvax.345 Posted: Thu Apr 28 16:40:18 1983 Received: Fri Apr 29 08:14:49 1983 RE: possible undesired optimization of code like: while (ADDR->c_reg&BUSY) ; I have worked with drivers a great deal in older versions of UNIX and never had a problem with optimization eliminating the repeated memory reference. One reason may be that since UNIX is a timesharing system, there are very few actual "busy waits" as above (a neat way to hang a system) but instead: while (ADDR->c_reg&BUSY) sleep((caddr_t)&x, PRIBIO); The subroutine call in the loop is enough to turn off any optimization. But otherwise, in the first example it would seem reasonable to optimize out the memory reference, to the programmer's displeasure. This could become a more widespread problem when shared data spaces cause user programs to use the same type of code. The "unregister" or "volatile" declaration mentioned could prove useful (I prefer the second term). Tom Beres {we13, mcnc, seismo}!rlgvax!tom