Slim Reader Writer Locks

In a recent internal thread, there's been some good discussion about the new Slim Reader Writer locks in Vista. See the SRWLockXXX functions for details.

A brief synopis of the key points about these locks:

Since XP, there's a new intra-process synchronization mechanism in the kernel called "keyed events". Basically you register a wait on a PVOID value, and you'll block until another thread in the same process signals with the same PVOID value. An MSN search on "keyed events" and "kernel" brings up a few bits of information.

 

This lets you build user mode synchronization primitives which have no extra kernel mode costs beyond the memory used for the synchronization primitive.

 

EnterCriticalSection() shouldn't fail any more - In low memory conditions, it falls back to using a keyed event.

 

SRW locks are lighter than critical sections. It's very fast to create & destroy them, and they use less memory. Consider using them in place of critical sections when it makes sense.

 

SRW locks don't support recursion semantics like critical sections do, and it's harder to debug threading issues, as the owner isn't tracked.

 

Key point: These are just the highlights of the discussion. I only learned about these locks a few days ago, so claim no expert status.

Comments

  • Anonymous
    October 19, 2006
    > An MSN search on "keyed events" and "kernel" brings up a few bits of information. So did a Google search.  It used to be that Google searches of MSDN brought more useful results than MSDN searches of MSDN, but then it started breaking and then MSN searches of MSDN brought more useful results than MSDN searches of MSDN, but recently MSN searches of MSDN have had trouble too.  Anyway a Google search found some write-ups by Mark Russinovich.  Now wondering if we should use keyed events or not since they're described as not documented. Anyway, you should have been able to write more information on these without trouble.  After all, Mr. Russinovich finished his writing before you started yours.  I accessed both concurrently, but that's because I was in read-only mode until

  • Anonymous
    December 13, 2006
    In a previous post , I mentioned the new slim reader/writer locks in Vista. A kind reader just sent me