kernel/eka/memmodel/epoc/flexible/mmu/mmu.cpp
branchRCL_3
changeset 28 5b5d147c7838
parent 26 c734af59ce98
child 41 0ffb4e86fcc9
--- a/kernel/eka/memmodel/epoc/flexible/mmu/mmu.cpp	Tue May 11 17:28:22 2010 +0300
+++ b/kernel/eka/memmodel/epoc/flexible/mmu/mmu.cpp	Tue May 25 14:09:55 2010 +0300
@@ -859,8 +859,14 @@
 		}
 #endif
 	TInt missing = iRamPageAllocator->AllocRamPages(aPages, aCount, aZonePageType, aBlockZoneId, aBlockRest);
-	if(missing && !(aFlags&EAllocNoPagerReclaim) && ThePager.GetFreePages(missing))
-		missing = iRamPageAllocator->AllocRamPages(aPages, aCount, aZonePageType, aBlockZoneId, aBlockRest);
+	if(missing && !(aFlags&EAllocNoPagerReclaim))
+		{
+		// taking the page cleaning lock here prevents the pager releasing the ram alloc lock
+		PageCleaningLock::Lock();  
+		if (ThePager.GetFreePages(missing))
+			missing = iRamPageAllocator->AllocRamPages(aPages, aCount, aZonePageType, aBlockZoneId, aBlockRest);
+		PageCleaningLock::Unlock();  
+		}
 	TInt r = missing ? KErrNoMemory : KErrNone;
 	if(r!=KErrNone)
 		iRamAllocFailed = ETrue;