ExInterlockedFreeToZone

PVOID
    ExInterlockedFreeToZone(

        IN PZONE_HEADER  Zone,
        IN PVOID  Block,
        IN PKSPIN_LOCK  Lock
        );

ExInterlockedFreeToZone places the given zone entry in the free block list for the zone.

Parameters

Zone
Points to the zone header controlling the storage for the entry.
Block
Points to the block of storage to be freed.
Lock
Points to the caller-supplied spin lock. The spin lock is released before returning to the caller.

Return Value

ExInterlockedFreeToZone returns a pointer to the previous block of storage that was at the head of the free list. NULL implies that the zone went from no available free blocks to at least one free block.

Comments

Support routines that do interlocked operations are assumed to be incapable of causing a page fault. That is, neither their code nor any of the data they touch can cause a page fault without bringing down the system. They use spin locks to achieve atomicity in SMP machines. The caller must provide resident storage for the Lock, which must be initialized with KeInitializeSpinLock before the initial call to an ExInterlockedXxx.

ExInterlockedFreeToZone updates the free block list while holding the given the spin lock so the list links are updated in a multiprocessor-safe way.

Any of the Ex..Interlocked routines can be called at DIRQL from a device driver’s ISR or SynchCritSection routines, provided that other driver routines do not make calls to the ExInterlockedXxx while running at < DIRQL with the same spin lock. Otherwise, callers of ExInterlockedFreeToZone must be running at IRQL <= DISPATCH_LEVEL.

See Also

ExInitializeZone, ExInterlockedAllocateFromZone, KeInitializeSpinLock