[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] memcpy() : problem when passing destination pointer
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] memcpy() : problem when passing destination pointer |
Date: |
Thu, 12 Feb 2009 06:59:13 +0100 (MET) |
Vincent Trouilliez <address@hidden> wrote:
> I can't find any reference to the volatile keyboard in the
> current avr-libc manual (1.6.2), [...]
Note that volatile is explained in the C standard.
> IIRC it said volatile must be used to keep the compiler from
> optimizing away access to a variable that he thinks might be
> pointless. Like writing a variable that is never read back.
Nope, if the variable is a global one, it will always be written.
Even in the canonical example, it's not that the compiler would
/never/ read the flag variable. The only thing that happens without
the volatile is that it reads the flag once (because it optimizes the
expensive memory access outside the loop), so it will eventually miss
the update to the variable that happens inside the ISR -- but it
doesn't "throw away" the variable access completely.
So in order to just pass some random value in an array between an ISR
and another thread, it doesn't need to be volatile, as long as the
receiver is not "spin looping" on a value out of that array.
--
cheers, J"org .-.-. --... ...-- -.. . DL8DTL
http://www.sax.de/~joerg/ NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, (continued)
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Vincent Trouilliez, 2009/02/10
- RE: [avr-gcc-list] memcpy() : problem when passing destination pointer, Weddington, Eric, 2009/02/10
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Vincent Trouilliez, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Bernard Fouché, 2009/02/11
- RE: [avr-gcc-list] memcpy() : problem when passing destination pointer, Dave Hansen, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Paulo Marques, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Bernard Fouché, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, David Kelly, 2009/02/11
- [avr-gcc-list] Re: memcpy() : problem when passing destination pointer, David Brown, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Graham Davies, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer,
Joerg Wunsch <=
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Pertti Kellomäki, 2009/02/12
- [avr-gcc-list] Re: memcpy() : problem when passing destination pointer, David Brown, 2009/02/12
Message not available
FW: [avr-gcc-list] memcpy() : problem when passing destination pointer, Michael, 2009/02/11