by ejd » Mon Apr 25, 2011 12:43 pm
You have it a little mixed up. A critical construct may be nested within a critical region as long as the names of the critical constructs are different. An atomic may be nested within a critical, because if you look at Section 2.8.5 atomic Construct, you will see that "atomic regions do not enforce exclusive access with respect to any critical or ordered regions that access the same storage location x". So you have to use an atomic if you are using an atomic elsewhere to update a storage location that both atomics are accessing.
The statement about data races is true, if an atomic happened to contain a critical region (or atomic) within the expression. Then it is possible that you could create a deadlock condition. However, all the spec is saying, is not allowing this to happen is not sufficient to prevent deadlocks. In the V3.1 specification atomic and critical are no longer allowed to be closely nested inside an atomic region.