home *** CD-ROM | disk | FTP | other *** search
- From: daveb@llama.rtech (David Brower)
-
- First, let me emphasise a point. The Posix proposal is not requesting a
- change in ANSI C. It is saying that if a vendor is providing an C
- environment that is supposed to work with shared variables, either in
- shared memory or through the use of threads, than that environment needs
- to meet some additional criteria to conform to 1003.4. Among these is
- that it not be necessary to put "volatile" in front of declaration in
- the universe for things to work right.
-
- In article <601@longway.TIC.COM> Ronald Guilmette <rfg@ics.UCI.EDU> writes:
- >From: Ronald Guilmette <rfg@ics.UCI.EDU>
- >In article <5106@rtech.rtech.com> I write:
- >>Posix 1003.4 is the "real time" extension to Posix. It encompasses
- >>shared memory and threads. By including these features it introduces
- >>some new restrictions on the compilation environment, the gist of
- >>which are that almost everything needs to be treated as "partially
- >>volatile" (my phrase). The purpose of this note is to explore the
- >>sense of the community tuned to ANSI C to see if this presents a
- >>problem. I *don't* have any problems with the proposed Posix
- >>restrictions, and in fact consider them essential. I do suspect that
- >>some compiler writers may have some objections. Some of the tricks
- >>now used by "hyper-optimizing" compilers would be illegal.
- >>
- >>The Draft 1003.4 Std. says in section 13.2:
- . . .
-
- >Is it just me or does this strike anyone else as being pure gibberish?
- >Are these "problems" defined somewhere? Perhaps with examples of how
- >these "problems" could crop up in some actual code?
-
- Yes, they are defined in the proposal; perhaps it is unfortunate that I
- did not chose to type is in in it's entirely, including all the EQN
- equations. Sorry. Many of Ron's rhetorical questions are answered
- there.
-
- >> ... further, using the volatile keyword to solve
- >> memory coherence problems is both error prone and inefficient.
- >
- >Compared to what? Do the people writing this stuff come from marketing
- >backgrounds?
-
- I believe the answer is "compared to having to compiler gurantee that
- the sorts of things that would cause problems are not done." I'm not in
- the Posix working group, so I can't speak for them.
-
- >> It is error prone because every variable accessed by more than one
- >> stream of execution must be marked volatile, and if the mark is
- >> forgotten the program might exhibit nondeterministic behavior.
- >
- >Yes. If you write incorrect code, it will function incorrectly. Is this
- >news to anyone?
-
- The Posix committee apparently does not feel that it is reasonable to
- require making programmer write "volatile" on nearly everything to
- insure correctness.
-
- >> The keyword causes inefficient code to be generated because any
- >> reference or store into a volatile variable must be immediately
- >> reflected in all other streams of execution, defeating any
- >> optimization or caching.
- >
-
- >The issue of the effect on caching efficiency of the use of "volatile" is
- >potentially a real one, but *only* for multiprocessors (or uni-processors
- >with write-back caches), and *only* when certain types of cache coherency
- >schemes or certain types of cache coherency hardware is used on the
- >multiprocessors in question. Even for such cases however, the effects
- >will probably be small for any realistic programs on good hardware.
-
- Those are mighty big "onlys" if it's your machine at issue!
-
- One major problem is linking in third party object modules to your
- shared memory or threading application, when you don't know if that
- object has had "volatile" sprinkled in enough places. It would be
- better if the complier just did the right thing, and did not do
- optimizations that were inappropriate in a shared memory system.
-
- I sure get the sense that this is a hot topic, though...
-
- thanks,
- -dB
-
- "Bo knows Elvis. Bo IS Elvis."
- David Brower: {amdahl, cpsc6a, mtxinu, sun}!rtech!daveb daveb@rtech.com
-
- Volume-Number: Volume 19, Number 45
-
-