 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
junky_fellow@yahoo.co.in Guest
|
Posted: Mon May 14, 2007 9:12 am Post subject: volatile variables |
|
|
Guys,
If I have a global variable, that is shared across multiple
threads on an SMP environment, then do I need to declare it as
volatile, so that a particular processor does not store and access its
vlaue fron the processor registers ?
thnaks in advance for any help ... |
|
| Back to top |
|
 |
Hari Guest
|
Posted: Mon May 14, 2007 9:12 am Post subject: Re: volatile variables |
|
|
junky_fellow (AT) yahoo (DOT) co.in je napisao:
| Quote: | Guys,
If I have a global variable, that is shared across multiple
threads on an SMP environment, then do I need to declare it as
volatile, so that a particular processor does not store and access its
vlaue fron the processor registers ?
thnaks in advance for any help ...
|
Having volatile type qualifier is mainly to do with the problems that
are encountered in real-time or embedded systems.
| Quote: | so that a particular processor does not store and access its
vlaue fron the processor registers
|
yes, volatile will use direct access, and probably switch of
optimization
| Quote: | If I have a global variable, that is shared across multiple
threads on an SMP environment, then do I need to declare it as
volatile
|
I think that you must use some thread locking mechanism, not volatile,
to use global variable with multiple threads. Search net for thread
locking
for your platform.
Best,
Zaharije Pasalic |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|