Author: arty
Date: Sun Dec 3 14:51:07 2006
New Revision: 25031
URL:
http://svn.reactos.org/svn/reactos?rev=25031&view=rev
Log:
Other part of python installer unregression (verified as necessary)
What's here fixes the problem but no doubt others will find at least the
changes to address space locking thoroughly objectionable.
Modified:
branches/arty-stable/reactos/ntoskrnl/ex/fmutex.c
branches/arty-stable/reactos/ntoskrnl/include/internal/mm.h
branches/arty-stable/reactos/ntoskrnl/mm/aspace.c
branches/arty-stable/reactos/ntoskrnl/mm/npool.c
Modified: branches/arty-stable/reactos/ntoskrnl/ex/fmutex.c
URL:
http://svn.reactos.org/svn/reactos/branches/arty-stable/reactos/ntoskrnl/ex…
==============================================================================
--- branches/arty-stable/reactos/ntoskrnl/ex/fmutex.c (original)
+++ branches/arty-stable/reactos/ntoskrnl/ex/fmutex.c Sun Dec 3 14:51:07 2006
@@ -39,6 +39,7 @@
(Thread == NULL) ||
(Thread->CombinedApcDisable != 0));
+ ASSERT(FastMutex);
ASSERT((Thread == NULL) || (FastMutex->Owner != Thread));
/* Decrease the count */
Modified: branches/arty-stable/reactos/ntoskrnl/include/internal/mm.h
URL:
http://svn.reactos.org/svn/reactos/branches/arty-stable/reactos/ntoskrnl/in…
==============================================================================
--- branches/arty-stable/reactos/ntoskrnl/include/internal/mm.h (original)
+++ branches/arty-stable/reactos/ntoskrnl/include/internal/mm.h Sun Dec 3 14:51:07 2006
@@ -243,8 +243,10 @@
PMEMORY_AREA MemoryAreaRoot;
PVOID LowestAddress;
struct _EPROCESS* Process;
+ HANDLE OwningThread;
PUSHORT PageTableRefCountTable;
ULONG PageTableRefCountTableSize;
+ USHORT LockCount;
} MADDRESS_SPACE, *PMADDRESS_SPACE;
typedef struct
Modified: branches/arty-stable/reactos/ntoskrnl/mm/aspace.c
URL:
http://svn.reactos.org/svn/reactos/branches/arty-stable/reactos/ntoskrnl/mm…
==============================================================================
--- branches/arty-stable/reactos/ntoskrnl/mm/aspace.c (original)
+++ branches/arty-stable/reactos/ntoskrnl/mm/aspace.c Sun Dec 3 14:51:07 2006
@@ -11,12 +11,12 @@
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
+#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, MmInitializeKernelAddressSpace)
#endif
-
/* GLOBALS ******************************************************************/
@@ -37,14 +37,32 @@
return;
}
+ DPRINT("LockAddressSpace(%x)\n", AddressSpace);
+
+ /* No need to lock the address space if we own it */
+ if (AddressSpace->OwningThread == PsGetCurrentThread())
+ {
+ DPRINT("LockAddressSpace: We own it: %d\n", AddressSpace->LockCount);
+ AddressSpace->LockCount++;
+ return;
+ }
+
if (AddressSpace->Process)
{
+ DPRINT("LockAddressSpace: First owner (P): %x\n",
PsGetCurrentThread());
ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&AddressSpace->Process->AddressCreationLock);
+ AddressSpace->OwningThread = PsGetCurrentThread();
+ AddressSpace->LockCount = 1;
}
else
{
+ DPRINT("LockAddressSpace: First owner: %x\n", PsGetCurrentThread());
ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&KernelAddressSpaceLock);
+ AddressSpace->OwningThread = PsGetCurrentThread();
+ AddressSpace->LockCount = 1;
}
+
+ DPRINT("LockAddressSpace: Done\n");
}
VOID
@@ -58,14 +76,28 @@
{
return;
}
+
+ DPRINT("UnlockAddressSpace(%x) -> count %d\n", AddressSpace,
AddressSpace->LockCount);
+
if (AddressSpace->Process)
{
-
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&AddressSpace->Process->AddressCreationLock);
+ if(--AddressSpace->LockCount == 0)
+ {
+ DPRINT("UnlockAddressSpace (P): Really unlock (0)\n", AddressSpace,
AddressSpace->LockCount);
+ AddressSpace->OwningThread = 0;
+
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&AddressSpace->Process->AddressCreationLock);
+ }
}
else
{
- ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&KernelAddressSpaceLock);
+ if(--AddressSpace->LockCount == 0)
+ {
+ DPRINT("UnlockAddressSpace: Really unlock (0)\n", AddressSpace,
AddressSpace->LockCount);
+ AddressSpace->OwningThread = 0;
+ ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&KernelAddressSpaceLock);
+ }
}
+ DPRINT("UnlockAddressSpace: Done\n");
}
VOID
@@ -113,6 +145,8 @@
AddressSpace->LowestAddress = MmSystemRangeStart;
}
AddressSpace->Process = Process;
+ AddressSpace->OwningThread = NULL;
+ AddressSpace->LockCount = 0;
if (Process != NULL)
{
ULONG Count;
Modified: branches/arty-stable/reactos/ntoskrnl/mm/npool.c
URL:
http://svn.reactos.org/svn/reactos/branches/arty-stable/reactos/ntoskrnl/mm…
==============================================================================
--- branches/arty-stable/reactos/ntoskrnl/mm/npool.c (original)
+++ branches/arty-stable/reactos/ntoskrnl/mm/npool.c Sun Dec 3 14:51:07 2006
@@ -271,7 +271,7 @@
return;
}
- for (p = n; p != y; p = q)
+ for (p = n; p && p != y; p = q)
{
q = p->parent;
dir = q->link[0] != p;