Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Tim Wescott <tim@seemywebsite.com> |
|---|---|
| Subject | Re: how to use volatile key word? |
| Newsgroups | comp.lang.c, comp.arch.embedded |
| References | <4fa787bc-0930-4c4e-a1e9-dbf94b909e8a@googlegroups.com> <FJCdnQHCbf30L3fSnZ2dnUVZ7tmdnZ2d@lyse.net> |
| Message-ID | <7-6dnSTYNeYVrXbSnZ2dnUVZ_iydnZ2d@web-ster.com> (permalink) |
| Date | 2012-06-27 11:10 -0500 |
Cross-posted to 2 groups.
On Wed, 27 Jun 2012 09:08:08 +0200, David Brown wrote: > On 26/06/2012 18:10, 伏虎 wrote: >> how to use volatile key word? >> >> Assume I have a global variable shared by two or more tasks. Do I need >> to declare it as volatile? >> >> When will a non-volatile global variable be written back to memory from >> a register copy? Before a function call? Or before the return >> statement? >> >> >> >> > > You have multi-posted this same question to multiple newsgroups - at > least comp.lang.c, comp.lang.c++, and comp.arch.embedded. This is bad > practice - if you think your question belongs in all groups, you should > cross-post a single post to all groups. That way there will be a single > discussion thread, and the embedded people and language lawyers can > discuss together. You are currently getting two sets of opinions as > seen from wildly different viewpoints. > > You must decide if you are talking about an embedded system or a > PC-style system. Are you talking about small, simple processors, or > large multi-core systems? Are you talking about interrupt tasks on a > microcontroller or multiple threads with an OS? Are you talking about > small pieces of data (single variables) or large blocks of data? > Depending on the answers, it could be "yes, volatile is all you need to > share the data" up to "no, volatile is such a small part of what you > need that it is not worth bothering about". > > Once you have figured out the right question, and the right details, > then re-post as a cross-post (or as just a single post, if you think > only one group is appropriate). Then we can help give you the right > advice. And if the terms "cross posting" and "multiple posting" mean nothing to you, check out this Wiki article: http://en.wikipedia.org/wiki/Cross_post. I had been unaware that the question had been posted to multiple groups: yes, you will get wildly different answers, because what's appropriate and applicable for an itty bitty processor with code running on bare metal is considerably different -- and often diametrically opposed to -- what's appropriate and applicable in an application running on a desktop. Consider a guy in camo pants with a pack full of freeze-dried food, armed with a long knife and a shotgun. Put him in Times Square -- is his gear appropriate and applicable? How about a lawyer in a shiny suit with $300 shoes, armed with a Visa Platinum? How's he doing? Now put those two guys out in the sticks in Alaska -- who's gear makes sense now? Ditto software practices in (deep) embedded vs. desktop. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to use volatile key word? 伏虎 <fuhu314@hotmail.com> - 2012-06-26 09:10 -0700
Re: how to use volatile key word? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2012-06-26 18:56 +0200
Re: how to use volatile key word? Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-26 12:57 -0400
Re: how to use volatile key word? Jens Gustedt <jens.gustedt@loria.fr> - 2012-06-26 21:06 +0200
Re: how to use volatile key word? David Brown <david@westcontrol.removethisbit.com> - 2012-06-27 09:08 +0200
Re: how to use volatile key word? Tim Wescott <tim@seemywebsite.com> - 2012-06-27 11:10 -0500
Re: how to use volatile key word? Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-27 10:28 -0700
csiph-web