/* Performs an atomic compare exchange operation to lock semaphore. The compare exchange operation must be performed using MP safe mechanisms. */
STATIC UINT32 InternalLockdownSemaphore(IN OUT volatile UINT32 *Sem)
/* Performs an atomic compare exchange operation to lock semaphore. The compare exchange operation must be performed using MP safe mechanisms. */
STATIC UINT32 InternalLockdownSemaphore(IN OUT volatile UINT32 *Sem)
{
  UINT32  Value;
  do {
    Value = *Sem;
  } while (InterlockedCompareExchange32 (
             (UINT32 *)Sem,
             Value,
             (UINT32)-1
             ) != Value);
  return Value;
}