- 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.

svn path=/trunk/; revision=32547
This commit is contained in:
Aleksey Bragin 2008-03-03 18:03:04 +00:00
parent 3171081397
commit fad1031b37
3 changed files with 34 additions and 9 deletions

View file

@ -167,13 +167,12 @@ ShutdownThreadMain(PVOID Context)
}
PspShutdownProcessManager();
CmShutdownSystem();
MiShutdownMemoryManager();
IoShutdownRegisteredFileSystems();
IoShutdownRegisteredDevices();
MiShutdownMemoryManager();
if (Action == ShutdownNoReboot)
{
HalDisplayString("\nYou can switch off your computer now\n");

View file

@ -57,6 +57,9 @@ ULONG_PTR MmPfnDatabaseEnd;
PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
extern KMUTANT MmSystemLoadLock;
extern HANDLE MpwThreadHandle;
extern BOOLEAN MpwThreadShouldTerminate;
extern KEVENT MpwThreadEvent;
BOOLEAN MiDbgEnableMdDump =
#ifdef _ARM_
TRUE;
@ -70,7 +73,33 @@ VOID
NTAPI
MiShutdownMemoryManager(VOID)
{
ULONG PagesWritten;
PETHREAD Thread;
/* Ask MPW thread to shutdown */
MpwThreadShouldTerminate = 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 @@ MmInit1(VOID)
MmPagedPoolBase = (PVOID)PAGE_ROUND_UP((ULONG_PTR)MiNonPagedPoolStart +
MiNonPagedPoolLength);
MmPagedPoolSize = MM_PAGED_POOL_SIZE;
/* Dump kernel memory layout */
MiDbgKernelLayout();
/* Initialize the page list */
MmInitializePageList();
/* Unmap low memory */
MmDeletePageTable(NULL, 0);

View file

@ -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 *****************************************************************/