what alternative to KeAcquireInStackQueuedSpinLock with much lower overhead but same functionality InterlockedCompareExchangePointer can be alternative ?
Why not use InterlockedCompareExchangePointer, if that's the functionality you need? It compiles to essentially 1 CPU instruction.
KeAcquireInStackQueuedSpinLock is a pretty low overhead lock if you need fairness. If you don't need fairness, there's good old KeAcquireSpinLock, which is basically an interlocked bit test and set.
What functionality do you need? And what leads you to believe you need "much lower overhead"??
"Traditional spin locks can lead to significant processor contention when multiple threads attempt to acquire the lock simultaneously, as they continuously loop (or "spin") checking the lock status. This can degrade system performance, especially on multiprocessor systems. Queued spin locks mitigate this by organizing threads into a queue. When a thread acquires a lock, only the next in line is actively spinning, waiting to acquire the lock. This reduces the CPU cycles wasted on spinning, especially when the lock is held for longer durations." (MSDN)
@lucianpin: Thank you for quoting for the documentation that I'm sure we've all read and are familiar with. Was that supposed to be helpful in some way?