From cebfcd7c5e5ca3ac4667b1c6935f85f29b5afdbe Mon Sep 17 00:00:00 2001 From: David Welch Date: Sun, 18 Mar 2001 21:28:30 +0000 Subject: [PATCH] One more bug in MmAllocateContiguousPages Removed debugging code svn path=/trunk/; revision=1715 --- reactos/install.sh | 3 ++- reactos/ntoskrnl/ke/main.c | 25 +------------------------ reactos/ntoskrnl/mm/freelist.c | 2 +- reactos/ntoskrnl/mm/wset.c | 30 +++++++++++++++++++++++++----- 4 files changed, 29 insertions(+), 31 deletions(-) diff --git a/reactos/install.sh b/reactos/install.sh index fb8d96b335f..c368aacda75 100644 --- a/reactos/install.sh +++ b/reactos/install.sh @@ -43,4 +43,5 @@ cp apps/uitest/uitest.exe $1/reactos/bin/ cp apps/gditest/gditest.exe $1/reactos/bin/ cp apps/ptest/ptest.exe $1/reactos/bin/ cp apps/timer/timer.exe $1/reactos/bin/ -cp apps/exp/exp.exe $1/reactos/bin \ No newline at end of file +cp apps/exp/exp.exe $1/reactos/bin/ +cp apps/alive/alive.exe $1/reactos/bin/ \ No newline at end of file diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index ec5c5ccbc73..c72f26da5d2 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: main.c,v 1.81 2001/03/18 19:35:12 dwelch Exp $ +/* $Id: main.c,v 1.82 2001/03/18 21:28:30 dwelch Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/main.c @@ -589,29 +589,6 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock) } } - DbgPrint("About to try MmAllocateContiguousAlignedMemory\n"); - do - { -extern PVOID STDCALL -MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN ULONG Alignment); - PVOID v; - PHYSICAL_ADDRESS p; - p.QuadPart = 16*1024*1024; - v = MmAllocateContiguousAlignedMemory(12*1024, p, - 64*1024); - if (v != NULL) - { - DbgPrint("Worked\n"); - } - else - { - DbgPrint("Failed\n"); - } - } - while (0); - /* Create the SystemRoot symbolic link */ DbgPrint("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine); CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine); diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index 073d7309dc8..c4955ade0e2 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -66,7 +66,7 @@ MmGetContinuousPages(ULONG NumberOfBytes, length = 0; for (i = 0; i < (HighestAcceptableAddress.QuadPart / PAGESIZE); ) { - if (MmPageArray[i].Flags & MM_PHYSICAL_PAGE_FREE) + if (MM_PTYPE(MmPageArray[i].Flags) == MM_PHYSICAL_PAGE_FREE) { if (start == -1) { diff --git a/reactos/ntoskrnl/mm/wset.c b/reactos/ntoskrnl/mm/wset.c index f30e6e38c6b..4c90970f0cf 100644 --- a/reactos/ntoskrnl/mm/wset.c +++ b/reactos/ntoskrnl/mm/wset.c @@ -1,4 +1,4 @@ -/* $Id: wset.c,v 1.7 2001/02/06 00:11:19 dwelch Exp $ +/* $Id: wset.c,v 1.8 2001/03/18 21:28:30 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -122,8 +122,8 @@ ULONG MmPageOutPage(PMADDRESS_SPACE AddressSpace, return(0); } -ULONG MmTrimWorkingSet(PEPROCESS Process, - ULONG ReduceHint) +ULONG +MmTrimWorkingSet(PEPROCESS Process, ULONG ReduceHint) { ULONG i, j; PMADDRESS_SPACE AddressSpace; @@ -178,14 +178,19 @@ ULONG MmTrimWorkingSet(PEPROCESS Process, return(Count); } -VOID MmRemovePageFromWorkingSet(PEPROCESS Process, - PVOID Address) +VOID +MmRemovePageFromWorkingSet(PEPROCESS Process, PVOID Address) + /* + * Remove a page from a process's working set + */ { ULONG i; PMADDRESS_SPACE AddressSpace; PVOID* WSet; ULONG j; + MmLockWorkingSet(Process); + WSet = (PVOID*)Process->WorkingSetPage; AddressSpace = &Process->AddressSpace; @@ -204,6 +209,7 @@ VOID MmRemovePageFromWorkingSet(PEPROCESS Process, AddressSpace->WorkingSetLruLast = AddressSpace->WorkingSetMaximumLength; } + MmUnlockWorkingSet(Process); return; } j = (j + 1) % AddressSpace->WorkingSetMaximumLength; @@ -214,6 +220,9 @@ VOID MmRemovePageFromWorkingSet(PEPROCESS Process, VOID MmAddPageToWorkingSet(PEPROCESS Process, PVOID Address) + /* + * Insert a page into a process's working set + */ { PVOID* WSet; PMADDRESS_SPACE AddressSpace; @@ -230,6 +239,11 @@ MmAddPageToWorkingSet(PEPROCESS Process, { KeBugCheck(0); } + + /* + * Lock the working set + */ + MmLockWorkingSet(Process); WSet = (PVOID*)Process->WorkingSetPage; @@ -246,6 +260,7 @@ MmAddPageToWorkingSet(PEPROCESS Process, PVOID Page; NTSTATUS Status; + /* FIXME: This isn't correct */ Page = MmAllocPageMaybeSwap(0); if (Page == 0) { @@ -270,6 +285,11 @@ MmAddPageToWorkingSet(PEPROCESS Process, AddressSpace->WorkingSetLruLast = (Current + 1) % AddressSpace->WorkingSetMaximumLength; AddressSpace->WorkingSetSize++; + + /* + * And unlock + */ + MmUnlockWorkingSet(Process); }