Re: [eigen] Help on solving a race condition

[ Thread Index | Date Index | More Archives ]

If you want to use volatile notice that written to a volatile int is
safe a least in C language (therefore extern C), because int read is
in pratice atomic and if not it will break a lot of code. Thus a
portable solution will be to compute your value in a tempory struct
  struct {
  char  m_l1CacheSize;
  char m_l2CacheSize;
  char power;
  char initialized;
  int word;
The problem with that solution is that's not possible to initialize
the 'initialized' or whole 'word' variable because they are part of a
You could do manually using bitfield or even simplier, if you could
guaranted that int is initialised to zero at init you test if it is
equal to zero, and write if not equal.Or if you are worried about
this, you could add a depend on libatomic see
And it is portable and it will not add a depend if you use thread,
because pthread and gcc use it internally.

The atomic stuff in C++11 is (or will be) even more portable:


Mail converted by MHonArc 2.6.19+