- Fix implementations of AcpiOsWaitSemaphore and AcpiOsAcquireMutex to obey the caller's demands to not block if requested

svn path=/trunk/; revision=56245
This commit is contained in:
Cameron Gutman 2012-03-27 07:23:14 +00:00
parent d45f75426f
commit ba5509bc72

View file

@ -298,7 +298,18 @@ AcpiOsAcquireMutex(
return AE_BAD_PARAMETER;
}
/* Check what the caller wants us to do */
if (Timeout == ACPI_DO_NOT_WAIT)
{
/* Try to acquire without waiting */
if (!ExTryToAcquireFastMutex((PFAST_MUTEX)Handle))
return AE_TIME;
}
else
{
/* Block until we get it */
ExAcquireFastMutex((PFAST_MUTEX)Handle);
}
return AE_OK;
}
@ -379,6 +390,16 @@ AcpiOsWaitSemaphore(
}
KeAcquireSpinLock(&Sem->Lock, &OldIrql);
/* Make sure we can wait if we have fewer units than we need */
if ((Timeout == ACPI_DO_NOT_WAIT) && (Sem->CurrentUnits < Units))
{
/* We can't so we must bail now */
KeReleaseSpinLock(&Sem->Lock, OldIrql);
return AE_TIME;
}
/* Time to block until we get enough units */
while (Sem->CurrentUnits < Units)
{
KeReleaseSpinLock(&Sem->Lock, OldIrql);