[Insight-developers] itkTimeStamp Test Failures Mistery
Tom Vercauteren
tom.vercauteren at m4x.org
Wed Feb 18 11:48:41 EST 2009
Hi Sean,
>>That's right but all optimized version use the same pattern:
>> m_ModifiedTime = (unsigned
>>long)some_atomic_increment_function(itkTimeStampTime);
>>which is why the problem might be in the cast and assign.
>
> I doubt the cast is problematic. However, looking at this code again,
> one thing does strike me:
>
> In the non-optimised case, both the increment and assignment to the
> instance variable m_ModifiedTime are within the critical section
> (protected by mutex). In the optimised cases, the increment is atomic,
> but the assignment to m_ModifiedTime is not. That could be a problem.
Even though I don't really understand how in our specific test case,
this could be a problem, I also agree that within that piece of code,
the assignment is the most suspicious operation...
> It would probably be better if m_ModifiedTime itself was passed to the
> various atomic increment functions. The "problem" there is that the
> type of m_ModifiedTime would need to be of different type/size on
> different platforms.
>
> I could attempt such a patch if you'd like...
Is this possible? itkTimeStampTime has to be a global (static)
variable whereas m_ModifiedTime has to be local (member). So unless
there is an atomic function that does "increment one variable and
assign its value to another", I think I am missing something.
Tom
More information about the Insight-developers
mailing list