volatile registers
Dennis L. Mumaugh
dlm at cuuxb.ATT.COM
Sat Jan 7 11:11:14 AEST 1989
In article <10720 at rpp386.Dallas.TX.US> jfh at rpp386.Dallas.TX.US
(The Beach Bum) writes:
>Shared memory has many applications which should be exploited.
As I alluded to in my article. Actually shared memory has so many
pitfalls, even volatile isn't safe. The WE32100 has a swapi
instruction that can be used for concurrency applications. Guess
what? Co-processors and caches do strange things then. I think
volatile is a very dangerous construct and can and will bite the user
unless s/he is VERY carefull.
>
>A common usage is in interrupt [ software ] handlers where the
>signal catching routine sets a flag and returns.
>
I received a lot of mail about this use. It is marginally
acceptable. It is only necessary with aggressive optimizers
that do strength reductions on while loops and the user does
a
while( ! intflag) sleep(10);
type of construct. Surely there are other better techniques.
I also saw comments that the constuct of a volatile register
was useful in setjmp/longjmp to preserve a register. Perhaps
Doug Gwyn can comment whether this was accepted by ANSI or not.
Any other use of a volatile register is not meaningful unless one uses
lightweight/multithread processes sharing registers and doing
concurrent execution and that is sufficently mindboggling that I'd
program it in a decent language like NELIAC [ half seriously now!].
--
=Dennis L. Mumaugh
Lisle, IL ...!{att,lll-crg}!cuuxb!dlm OR cuuxb!dlm at arpa.att.com
More information about the Comp.std.c
mailing list