Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Date | 2012-06-27 09:08 +0200 |
|---|---|
| From | David Brown <david@westcontrol.removethisbit.com> |
| Newsgroups | comp.lang.c, comp.arch.embedded |
| Subject | Re: how to use volatile key word? |
| References | <4fa787bc-0930-4c4e-a1e9-dbf94b909e8a@googlegroups.com> |
| Message-ID | <FJCdnQHCbf30L3fSnZ2dnUVZ7tmdnZ2d@lyse.net> (permalink) |
Cross-posted to 2 groups.
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.
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