Replace critical section with SRW lock Replace critical section with SRW lock multithreading multithreading

Replace critical section with SRW lock


See Joe Duffy's book "Concurrent Programming on Windows", pg 289.

The short answer to your question is "almost". There are semantics with recursively acquired CRITICAL_SECTION's that are different for SRWL's. If your program took advantage of these characteristics of Win32's critical sections, then you can't wholesale switch to SRWL easily. You could, however, wrap an SRWL in a wrapper to provide CS like semantics, but there are a bunch of subtleties in doing so, so you are better off sticking to CS's if you are depending on such behavior.

Kenny Kerr's article describes a little about how both are implemented internally.