Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!wivax!decvax!decwrl!sun!megatest!ubvax!arvind From: arvind@ubvax.UUCP Newsgroups: net.lang.c Subject: Re: RE: C and real hardware - (nf) Message-ID: <128@ubvax.UUCP> Date: Sat, 25-Jun-83 14:27:10 EDT Article-I.D.: ubvax.128 Posted: Sat Jun 25 14:27:10 1983 Date-Received: Sun, 26-Jun-83 02:13:35 EDT Lines: 29 #R:rlgvax:-34500:ubvax:4100001:000:981 ubvax!arvind Apr 29 19:10:00 1983 ***** ubvax:net.lang.c / rlgvax!tom / 4:40 pm Apr 28, 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 ----------