- Change dispatcher lock release to be more like documented in Windows Internals...
authorAlex Ionescu <aionescu@gmail.com>
Thu, 5 Jan 2006 15:32:08 +0000 (15:32 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Thu, 5 Jan 2006 15:32:08 +0000 (15:32 +0000)
svn path=/trunk/; revision=20579

reactos/ntoskrnl/include/internal/ke.h
reactos/ntoskrnl/ke/wait.c

index 30bf212..9c8a49a 100644 (file)
@@ -51,6 +51,7 @@ extern ULONG_PTR KERNEL_BASE;
 #ifndef CONFIG_SMP
 #define KeInitializeDispatcher()
 #define KeAcquireDispatcherDatabaseLock() KeRaiseIrqlToDpcLevel();
 #ifndef CONFIG_SMP
 #define KeInitializeDispatcher()
 #define KeAcquireDispatcherDatabaseLock() KeRaiseIrqlToDpcLevel();
+#define KeReleaseDispatcherDatabaseLock(OldIrql) KiExitDispatcher(OldIrql);
 #define KeAcquireDispatcherDatabaseLockAtDpcLevel()
 #define KeReleaseDispatcherDatabaseLockFromDpcLevel()
 #else
 #define KeAcquireDispatcherDatabaseLockAtDpcLevel()
 #define KeReleaseDispatcherDatabaseLockFromDpcLevel()
 #else
@@ -60,6 +61,9 @@ extern ULONG_PTR KERNEL_BASE;
     KeAcquireSpinLockAtDpcLevel (&DispatcherDatabaseLock);
 #define KeReleaseDispatcherDatabaseLockFromDpcLevel() \
     KeReleaseSpinLockFromDpcLevel(&DispatcherDatabaseLock);
     KeAcquireSpinLockAtDpcLevel (&DispatcherDatabaseLock);
 #define KeReleaseDispatcherDatabaseLockFromDpcLevel() \
     KeReleaseSpinLockFromDpcLevel(&DispatcherDatabaseLock);
+#define KeReleaseDispatcherDatabaseLock(OldIrql) \
+    KeReleaseSpinLockFromDpcLevel(&DispatcherDatabaseLock); \
+    KiExitDispatcher(OldIrql);
 #endif
 
 /* The following macro initializes a dispatcher object's header */
 #endif
 
 /* The following macro initializes a dispatcher object's header */
@@ -259,6 +263,10 @@ VOID
 STDCALL
 KiAdjustQuantumThread(IN PKTHREAD Thread);
 
 STDCALL
 KiAdjustQuantumThread(IN PKTHREAD Thread);
 
+VOID
+FASTCALL
+KiExitDispatcher(KIRQL OldIrql);
+
 /* gmutex.c ********************************************************************/
 
 VOID
 /* gmutex.c ********************************************************************/
 
 VOID
@@ -386,10 +394,6 @@ KiExpireTimers(
     PVOID SystemArgument2
 );
 
     PVOID SystemArgument2
 );
 
-VOID
-FASTCALL
-KeReleaseDispatcherDatabaseLock(KIRQL Irql);
-
 VOID
 STDCALL
 KeInitializeThread(
 VOID
 STDCALL
 KeInitializeThread(
index 79b18f6..fad80d9 100644 (file)
@@ -798,7 +798,7 @@ KiAcquireFastMutex(IN PFAST_MUTEX FastMutex)
 
 VOID
 FASTCALL
 
 VOID
 FASTCALL
-KeReleaseDispatcherDatabaseLock(KIRQL OldIrql)
+KiExitDispatcher(KIRQL OldIrql)
 {
     /* If it's the idle thread, dispatch */
     if (!(KeIsExecutingDpc()) &&
 {
     /* If it's the idle thread, dispatch */
     if (!(KeIsExecutingDpc()) &&
@@ -807,17 +807,10 @@ KeReleaseDispatcherDatabaseLock(KIRQL OldIrql)
         (KeGetCurrentThread() == KeGetCurrentPrcb()->IdleThread))
     {
         KiDispatchThreadNoLock(Ready);
         (KeGetCurrentThread() == KeGetCurrentPrcb()->IdleThread))
     {
         KiDispatchThreadNoLock(Ready);
-        KeLowerIrql(OldIrql);
-    }
-    else
-    {
-        /* Just release the spin lock */
-#ifdef CONFIG_SMP
-        KeReleaseSpinLock(&DispatcherDatabaseLock, OldIrql);
-#else
-        KeLowerIrql(OldIrql);
-#endif
     }
     }
+
+    /* Lower irql back */
+    KeLowerIrql(OldIrql);
 }
 
 /* EOF */
 }
 
 /* EOF */