Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: AvrStudio4 (2008), WinAVR (2007-05...) and Dragon problem debugging C code (jtag)

2008-06-10 by Robert Adsett

At 12:49 AM 6/10/2008 +0000, Graham Davies wrote:
>David Kelly wrote:
> > Volatile informs the compiler that
> > the object may change between the
> > compiler's uses ... And when changing
> > the value it must write it out
> > immediately. And not merge the access
> > across multiple statements.
>
>then, Robert Adsett wrote:
> > What it actually means though is that
> > access to a volatile variable must
> > take place in the order they are
> > specified and exactly as many times
> > as is specified.
>
>But, that exactly what David wrote!

Not quite.  "informs the compiler the object may change between uses" can 
be read to guarantee behaviour volatile does not.  In particular volatile 
does not assure atomic access.

The compiler is also allowed to reorder access's to non-volatile variables 
around the volatile accesses, so if you had a set of volatile writes and 
non-volatile writes in a routine the volatile writes could be optimized to 
be placed anywhere in the routine as long as their order remained the same, 
"must write it out immediately" could be taken as a stronger assurance.

Quibbles to be sure but when you are working with volatile such quibbles 
can mean a broken program.

Robert


"C is known as a language that gives you enough rope to shoot yourself in
the foot."  -- David Brown in comp.arch.embedded
http://www.aeolusdevelopment.com/

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.