[ros-diffs] [cgutman] 56245: [ACPI] - Fix implementations of AcpiOsWaitSemaphore and AcpiOsAcquireMutex to obey the caller's demands to not block if requested

cgutman at svn.reactos.org cgutman at svn.reactos.org
Tue Mar 27 07:23:15 UTC 2012


Author: cgutman
Date: Tue Mar 27 07:23:14 2012
New Revision: 56245

URL: http://svn.reactos.org/svn/reactos?rev=56245&view=rev
Log:
[ACPI]
- Fix implementations of AcpiOsWaitSemaphore and AcpiOsAcquireMutex to obey the caller's demands to not block if requested

Modified:
    trunk/reactos/drivers/bus/acpi/osl.c

Modified: trunk/reactos/drivers/bus/acpi/osl.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/osl.c?rev=56245&r1=56244&r2=56245&view=diff
==============================================================================
--- trunk/reactos/drivers/bus/acpi/osl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/osl.c [iso-8859-1] Tue Mar 27 07:23:14 2012
@@ -298,8 +298,19 @@
         return AE_BAD_PARAMETER;
     }
 
-    ExAcquireFastMutex((PFAST_MUTEX)Handle);
-    
+    /* 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;
 }
 
@@ -377,8 +388,18 @@
         DPRINT1("Bad parameter\n");
         return AE_BAD_PARAMETER;
     }
-    
+
     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);




More information about the Ros-diffs mailing list