Answer by Michael Burr for Compiler reordering around mutex boundaries?
It can not possibly know how will I implement these functions in some other compilation unit.This is the key - since the compiler cannot know (in general) about the implementation of the function...
View ArticleAnswer by Potatoswatter for Compiler reordering around mutex boundaries?
You're right, that code is correct and safe. I did think of a "code joke," though.pthread_mutex_lock( &mx ) + foo() + pthread_mutex_unlock( &mx );
View ArticleAnswer by Diego Sevilla for Compiler reordering around mutex boundaries?
As it is written, if the functions are not inline, the compiler won't move the variable assignation, as the call may be unrelated to the _field variable, but it has to preserve the strict order of...
View ArticleAnswer by Mark Ransom for Compiler reordering around mutex boundaries?
If the compiler can't guarantee that the function calls won't have side effects that will modify the variables between the calls, it can't move the code. If the variable is a local variable and you've...
View ArticleAnswer by 500 - Internal Server Error for Compiler reordering around mutex...
In general, a compiler will not move code around unless it knows with certainty that doing so will not affect run-time behavior.
View ArticleAnswer by Alexander V for Compiler reordering around mutex boundaries?
If compiler was doing so that'd be a bad compiler. ;-)
View ArticleCompiler reordering around mutex boundaries?
Suppose I have my own non-inline functions LockMutex and UnlockMutex, which are using some proper mutex - such as boost - inside. How will the compiler know not to reorder other operations with regard...
View Article
More Pages to Explore .....