--- In AVR-Chat@yahoogroups.com, Bob Paddock <bob.paddock@...> wrote:
>> The volatile attribute is precisely the solution for *any*
>> situation where a variable can be changed by an outside actor
> No. http://blog.regehr.org/archives/28 "Nine ways to break your
> systems code using volatile" See #8.
We may be arguing different points. Consider the code below with two tasks in a preemptive task switching environment. I don't claim that one should write task code like this. I do claim that if one does write code like this in such an environment, myFlag *must* be volatile.
uint8_t myFlag;
void task1(void)
{
// do something
while (!myFlag)
;
// do something else
}
void task2(void)
{
// do something
myFlag = 1;
// do something else
}
Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.netMessage
Re: gcc compiler bad behaviour
2012-04-14 by Don Kinzer
Attachments
- No local attachments were found for this message.