[ros-diffs] [fireball] 32547: - Implement MiShutdownMemoryManager (stops MPW thread and writes all dirty pages to disk). - Move MiShutdownMemoryManager invocation to where it should really happen (before filesystems shutdown). - As a result, MPW doesn't have a chance to flush pages when filesystems are already down. However, 1st assertion as mentioned in bug 2872 still happens. 2nd one is gone. See issue #2872 for more details.

fireball at svn.reactos.org fireball at svn.reactos.org
Sun Mar 9 12:32:55 CET 2008


Author: fireball
Date: Mon Mar  3 19:03:04 2008
New Revision: 32547

URL: http://svn.reactos.org/svn/reactos?rev=3D32547&view=3Drev
Log:
- Implement MiShutdownMemoryManager (stops MPW thread and writes all dirty =
pages to disk).
- Move MiShutdownMemoryManager invocation to where it should really happen =
(before filesystems shutdown).
- As a result, MPW doesn't have a chance to flush pages when filesystems ar=
e already down. However, 1st assertion as mentioned in bug 2872 still happe=
ns. 2nd one is gone.
See issue #2872 for more details.

Modified:
    trunk/reactos/ntoskrnl/ex/shutdown.c
    trunk/reactos/ntoskrnl/mm/mminit.c
    trunk/reactos/ntoskrnl/mm/mpw.c

Modified: trunk/reactos/ntoskrnl/ex/shutdown.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/shutdown.=
c?rev=3D32547&r1=3D32546&r2=3D32547&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/ex/shutdown.c (original)
+++ trunk/reactos/ntoskrnl/ex/shutdown.c Mon Mar  3 19:03:04 2008
@@ -167,12 +167,11 @@
      }
 =

    PspShutdownProcessManager();
-   =

+
    CmShutdownSystem();
+   MiShutdownMemoryManager();
    IoShutdownRegisteredFileSystems();
    IoShutdownRegisteredDevices();
-
-   MiShutdownMemoryManager();
 =

    if (Action =3D=3D ShutdownNoReboot)
      {

Modified: trunk/reactos/ntoskrnl/mm/mminit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?=
rev=3D32547&r1=3D32546&r2=3D32547&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/mm/mminit.c (original)
+++ trunk/reactos/ntoskrnl/mm/mminit.c Mon Mar  3 19:03:04 2008
@@ -57,6 +57,9 @@
 PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
 MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
 extern KMUTANT MmSystemLoadLock;
+extern HANDLE MpwThreadHandle;
+extern BOOLEAN MpwThreadShouldTerminate;
+extern KEVENT MpwThreadEvent;
 BOOLEAN MiDbgEnableMdDump =3D
 #ifdef _ARM_
 TRUE;
@@ -70,7 +73,33 @@
 NTAPI
 MiShutdownMemoryManager(VOID)
 {
-
+    ULONG PagesWritten;
+    PETHREAD Thread;
+
+    /* Ask MPW thread to shutdown */
+    MpwThreadShouldTerminate =3D TRUE;
+    KeSetEvent(&MpwThreadEvent, IO_NO_INCREMENT, FALSE);
+
+    /* Wait for it */
+    ObReferenceObjectByHandle(MpwThreadHandle,
+                              THREAD_ALL_ACCESS,
+                              PsThreadType,
+                              KernelMode,
+                              (PVOID*)&Thread,
+                              NULL);
+
+    KeWaitForSingleObject(Thread,
+                          Executive,
+                          KernelMode,
+                          FALSE,
+                          NULL);
+
+    ObDereferenceObject(Thread);
+
+    /* Check if there are any dirty pages, and flush them.
+       There will be no other chance to do this later, since filesystems
+       are going to be shut down. */
+    CcRosFlushDirtyPages(128, &PagesWritten);
 }
 =

 VOID
@@ -401,13 +430,10 @@
     MmPagedPoolBase =3D (PVOID)PAGE_ROUND_UP((ULONG_PTR)MiNonPagedPoolStar=
t +
                                            MiNonPagedPoolLength);
     MmPagedPoolSize =3D MM_PAGED_POOL_SIZE;
-    =

     /* Dump kernel memory layout */
     MiDbgKernelLayout();
-    =

     /* Initialize the page list */
     MmInitializePageList();
-    =

     /* Unmap low memory */
     MmDeletePageTable(NULL, 0);
 =


Modified: trunk/reactos/ntoskrnl/mm/mpw.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mpw.c?rev=
=3D32547&r1=3D32546&r2=3D32547&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/mm/mpw.c (original)
+++ trunk/reactos/ntoskrnl/mm/mpw.c Mon Mar  3 19:03:04 2008
@@ -17,10 +17,10 @@
 =

 /* GLOBALS ***************************************************************=
****/
 =

-static HANDLE MpwThreadHandle;
+HANDLE MpwThreadHandle;
 static CLIENT_ID MpwThreadId;
-static KEVENT MpwThreadEvent;
-static volatile BOOLEAN MpwThreadShouldTerminate;
+KEVENT MpwThreadEvent;
+BOOLEAN MpwThreadShouldTerminate;
 =

 /* FUNCTIONS *************************************************************=
****/
 =





More information about the Ros-diffs mailing list