https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a8322459abcd634256d1e61b04c4d1f35d6c2c90

commit a8322459abcd634256d1e61b04c4d1f35d6c2c90
Author:     Thamatip Chitpong <thamatip.chitp...@reactos.org>
AuthorDate: Tue Dec 24 15:30:58 2024 +0700
Commit:     Thamatip Chitpong <thamatip.chitp...@reactos.org>
CommitDate: Wed Jan 15 16:10:55 2025 +0700

    [NTOS:MM] balance: Fix PageOutThreadActive value check
---
 ntoskrnl/mm/balance.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/mm/balance.c b/ntoskrnl/mm/balance.c
index 3b11aeab2c8..bdb50c78707 100644
--- a/ntoskrnl/mm/balance.c
+++ b/ntoskrnl/mm/balance.c
@@ -289,7 +289,7 @@ VOID
 NTAPI
 MmRebalanceMemoryConsumers(VOID)
 {
-    // if (InterlockedCompareExchange(&PageOutThreadActive, 0, 1) == 0)
+    if (InterlockedCompareExchange(&PageOutThreadActive, 1, 0) == 0)
     {
         KeSetEvent(&MiBalancerEvent, IO_NO_INCREMENT, FALSE);
     }
@@ -404,7 +404,11 @@ MiBalancerThread(PVOID Unused)
             while (InitialTarget != 0);
 
             if (Status == STATUS_WAIT_0)
-                InterlockedDecrement(&PageOutThreadActive);
+            {
+                LONG Active = InterlockedExchange(&PageOutThreadActive, 0);
+                ASSERT(Active == 1);
+                DBG_UNREFERENCED_LOCAL_VARIABLE(Active);
+            }
         }
         else
         {

Reply via email to