- Change dispatcher lock release to be more like documented in Windows Internals II and to allow an easier move to Queued Spinlock.
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
Modified: trunk/reactos/ntoskrnl/ke/wait.c

Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
--- trunk/reactos/ntoskrnl/include/internal/ke.h	2006-01-05 15:29:08 UTC (rev 20578)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h	2006-01-05 15:32:08 UTC (rev 20579)
@@ -51,6 +51,7 @@
 #ifndef CONFIG_SMP
 #define KeInitializeDispatcher()
 #define KeAcquireDispatcherDatabaseLock() KeRaiseIrqlToDpcLevel();
+#define KeReleaseDispatcherDatabaseLock(OldIrql) KiExitDispatcher(OldIrql);
 #define KeAcquireDispatcherDatabaseLockAtDpcLevel()
 #define KeReleaseDispatcherDatabaseLockFromDpcLevel()
 #else
@@ -60,6 +61,9 @@
     KeAcquireSpinLockAtDpcLevel (&DispatcherDatabaseLock);
 #define KeReleaseDispatcherDatabaseLockFromDpcLevel() \
     KeReleaseSpinLockFromDpcLevel(&DispatcherDatabaseLock);
+#define KeReleaseDispatcherDatabaseLock(OldIrql) \
+    KeReleaseSpinLockFromDpcLevel(&DispatcherDatabaseLock); \
+    KiExitDispatcher(OldIrql);
 #endif
 
 /* The following macro initializes a dispatcher object's header */
@@ -259,6 +263,10 @@
 STDCALL
 KiAdjustQuantumThread(IN PKTHREAD Thread);
 
+VOID
+FASTCALL
+KiExitDispatcher(KIRQL OldIrql);
+
 /* gmutex.c ********************************************************************/
 
 VOID
@@ -387,10 +395,6 @@
 );
 
 VOID
-FASTCALL
-KeReleaseDispatcherDatabaseLock(KIRQL Irql);
-
-VOID
 STDCALL
 KeInitializeThread(
     struct _KPROCESS* Process,

Modified: trunk/reactos/ntoskrnl/ke/wait.c
--- trunk/reactos/ntoskrnl/ke/wait.c	2006-01-05 15:29:08 UTC (rev 20578)
+++ trunk/reactos/ntoskrnl/ke/wait.c	2006-01-05 15:32:08 UTC (rev 20579)
@@ -798,7 +798,7 @@
 
 VOID
 FASTCALL
-KeReleaseDispatcherDatabaseLock(KIRQL OldIrql)
+KiExitDispatcher(KIRQL OldIrql)
 {
     /* If it's the idle thread, dispatch */
     if (!(KeIsExecutingDpc()) &&
@@ -807,17 +807,10 @@
         (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 */