comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Pragma Volatile
Date: Sat, 29 Sep 2001 22:28:41 GMT
Date: 2001-09-29T22:28:41+00:00	[thread overview]
Message-ID: <3BB64B13.81AFFB4D@acm.org> (raw)
In-Reply-To: m3ofnt26xq.fsf@wf-rch.cirr.com

minyard@acm.org wrote:
> 
> Tucker Taft <stt@avercom.net> writes:
> 
> > There shouldn't be any problem if you are using this in a mono-processor.
>   (talking about volatiles not being important on uniprocessors).

From my reading of Taft's post, he did not say that pragma Volatile was
unimportant on uniprocessors. He said that achieving the desired
volatility is not a problem on uniprocessors; that you can count on the
compiler locating an object at an appropriate location if pragma
Volatile applies to it.

> Also, consider a register to reset a device, where you write a 0 then
> a 1 to reset it.
> 
>   B : Register_Access;
> 
>   B.all := 0;
>   B.all := 1;
> 
> Again, a compiler can say, "Hey, we can just ignore the first
> operation, because it doesn't have any effect", from the compiler's
> point of view.  But setting B volatile guarantees that both operations
> get done.  Actually, I'm not sure of the syntax here, because what B
> references is volatile, not B itself.  So I'm guessing you would have
> 
>   type Register_Access is access all Integer;
>   pragma Volatile(Register_Access);

If a register is an Integer, I would generally do

B : Integer;
for B'Address use Register_Location;
pragma Volatile (B);
...
B := 0;
B := 1;

But then, I don't have the C pointer fixation.

-- 
Jeff Carter
"Go and boil your bottoms."
Monty Python & the Holy Grail



  reply	other threads:[~2001-09-29 22:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-25 14:07 Pragma Volatile Jon R. Harshaw
2001-09-25 14:23 ` David C. Hoos
2001-09-25 14:38 ` Marin David Condic
2001-09-25 23:03 ` Mark Johnson
2001-09-29 17:38   ` Tucker Taft
2001-09-29 18:22     ` minyard
2001-09-29 22:28       ` Jeffrey Carter [this message]
2001-09-30 13:10         ` Robert Dewar
2001-09-30 21:19           ` Jeffrey Carter
2001-10-01  2:58             ` minyard
2001-10-02  9:38           ` AG
2001-10-02 10:59             ` Jeff Creem
2001-09-30  2:03       ` DuckE
2001-09-30 13:01       ` Robert Dewar
2001-09-30 20:12         ` minyard
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox