Let's say variable A is modified inside the body of the OpenMP critical section, and also assume that this variable A is also modified outside the critical section without critical construct but still inside the parallel region. I just wanted to know if critical section would protect update to this variable (which might happen outside) or not while one of the threads are inside the critical region? Thanks.
1 Answers
2
votes
No, the critical section only 'protects' updates made inside the section. Any update to the 'protected' variables outside the critical section leaves those variable unprotected. And don't forget, the critical section means that only one thread at a time executes the code that it (the critical section) encloses.
This seems entirely obvious so makes me wonder why you ask the question and what, perhaps, you are trying to achieve.