Exit critical region
问题 Consider several threads executing concurrently the following code: long gf = 0;// global variable or class member //... if (InterlockedCompareExchange(&gf, 1, 0)==0) // lock cmpxchg { // some exclusive code - must not execute in concurrent gf = 0; // this is ok ? or need //InterlockedExchange(&gf, 0); // [lock] xchg } Treat the code above as C-like pseudo-code, which will be translated more-or-less directly into assembly without the usual concessions to compiler optimizations such as re