Semaphores revisited, or the rundown protection object

I think that everybody on this forum remember the recent discussion on queues and semaphores in Windows (Anton surely should remember it at least).

Recently I have found the really amazing object in Windows - rundown protection.

This object, unlike semaphore, is really the thing. I remember writing something similar at least 3 times.

Unlike the semaphore which is a theoretical thing, this object is really useful in lots of situations.

Is there any chances MS will document this object, and its faster patented (http://www.freepatentsonline.com/7571288.html) cache-aware form?


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

I understand the question was, explicitly,“will MS *document* this”… but aren’t the functions that use these locks in WDM.H? The functions ExAllocateCacheAwareRundownProtection and friends??

Peter
OSR

>these locks in WDM.H? The functions ExAllocateCacheAwareRundownProtection and friends??

Yes, this is one of the cases of “present in WDK headers but not documented”.

There were several such cases, and rundown protection is one of them.

The object is really extremely useful, and documenting it would help 3rd parties to develop high performance kernel stuff.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

You have to be in a VERY hot code path causing tons of reference/dereference cycles, and on a NUMA machine as well, before you’d really NEED the kinds of optimization provided by this lock… would you not?

I mean, how big a problem IS cache pinging on ordinary interlocked compare/exchange… and at what point do you care?

Peter
OSR

> You have to be in a VERY hot code path causing tons of reference/dereference cycles

Filter drivers can easily have such paths.

, and on a NUMA machine as well

Well, even on non-NUMA the cache-aware optimization can do lots of good, and, also, this whole NUMA issue is about cache-aware rundown ref vs. old-style rundown ref, not about old-style rundown ref vs. it’s poor man’s version of spinlock+count+event.

I mean, how big a problem IS cache pinging on ordinary interlocked compare/exchange

This is cache-aware rundown vs. old-style rundown (the latter is “ordinary interlocked compare/exchange”).

If Windows itself uses these objects internally - then why it would be bad to advertise them for 3rd party filter writers, so that they will not slow the OS down by their products?


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

I agree… I suggest you go directly to the Community WDK Bug Bash here on OSR Online, and file a bug against the docs that says these functions are useful, are presently in WDM.H, but are not documented.

There is a reasonably good chance that these functions were put in WDM.H but that nobody bothered alterting the doc folks to write the doc pages for them.

Peter
OSR

What is rundown protection? Is it the same primitive as used by the remove lock?

No, it is not. See the patent that Max cited above for a very complete and interesting description of the “cache aware” flavors of Rundown Protection.

It IS cute stuff, I admit.

Peter
OSR