home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / aix / 13214 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  1.6 KB

  1. Path: sparky!uunet!mcsun!sun4nl!orcenl!dk.oracle.com!bengsig
  2. From: bengsig@dk.oracle.com (Bjorn Engsig)
  3. Newsgroups: comp.unix.aix
  4. Subject: Re: optimisation and volatile
  5. Message-ID: <1993Jan12.105241.20359@dk.oracle.com>
  6. Date: 12 Jan 93 10:52:41 GMT
  7. References: <PHIL.93Jan7143750@lurch.dhcs.demon.co.uk>
  8. Sender: news@dk.oracle.com (News Administrator)
  9. Reply-To: bengsig@dk.oracle.com (Bjorn Engsig)
  10. Organization: Oracle Denmark
  11. Lines: 22
  12. Nntp-Posting-Host: dkaix1.dk.oracle.com
  13.  
  14. Article <PHIL.93Jan7143750@lurch.dhcs.demon.co.uk> by phil@dhcs.demon.co.uk (phil) says:
  15. |would like to compile the code with -O optimization. The last time we tried
  16. |this the compiler would remove repeated shared memory reads with no intervening
  17. |writes,
  18. How should the compiler know that it needs to reload the data?  We've had
  19. examples of the opposite: data are loaded even though they weren't needed,
  20. and if the data was in unallocated shared memory, you'd get a segmentation
  21. violation.  E.g.:  if(a) b++; may lay load b even if a is zero.  Declaring
  22. b volatile avoids this [the actual code was more complicated than this].
  23.  
  24. As you suggest yourself:
  25. |gcc has a switch `-fvolatile' : Consider all memory references through pointers
  26. |to be volatile.
  27. But why would you force all references to be considered volatile? The only
  28. resonable solution is to declare your volatile variables as volatile.
  29. |Is there an equivalent for xlc?
  30. Not that I know of.
  31. -- 
  32. Bjorn Engsig,           Internet: bengsig@oracle.com   uucp: uunet!oracle!bengsig
  33. ORACLE Corporation.    Private : bjorn@login.dkuug.dk.
  34.  
  35. Every program uses a constant amount of memory, if memory is counted in dollars.
  36.