kerneltest/f32test/demandpaging/t_nandpaging.cpp
changeset 132 e4a7b1cbe40c
parent 123 fc55edbf3919
child 221 39b39e1a406e
equal deleted inserted replaced
131:e880629062dd 132:e4a7b1cbe40c
   275 				
   275 				
   276 					TPtr8 statsBuf((TUint8*) &stats, sizeof(stats));
   276 					TPtr8 statsBuf((TUint8*) &stats, sizeof(stats));
   277 					Drive.ControlIO(KNandGetDeferStats,statsBuf,0);
   277 					Drive.ControlIO(KNandGetDeferStats,statsBuf,0);
   278 					test.Printf(_L("PG %d PO %d(%d%%) NG %d NO %d\n"),stats.iPageGarbage,  stats.iPageOther, (TInt) ((stats.iPageOther*100)/cCount), stats.iNormalGarbage,  stats.iNormalOther);
   278 					test.Printf(_L("PG %d PO %d(%d%%) NG %d NO %d\n"),stats.iPageGarbage,  stats.iPageOther, (TInt) ((stats.iPageOther*100)/cCount), stats.iNormalGarbage,  stats.iNormalOther);
   279 
   279 
   280 					test(stats.iPageOther>0);
       
   281 				 	pageGarbageCount+=stats.iPageGarbage; 
   280 				 	pageGarbageCount+=stats.iPageGarbage; 
   282 				 	pageOtherCount+=stats.iPageOther;			 	
   281 				 	pageOtherCount+=stats.iPageOther;			 	
   283 				 	normalGarbageCount+=stats.iNormalGarbage; 
   282 				 	normalGarbageCount+=stats.iNormalGarbage; 
   284 				 	normalOtherCount+=stats.iNormalOther;			 	
   283 				 	normalOtherCount+=stats.iNormalOther;			 	
   285 					}
   284 					}
   299 
   298 
   300 		if (CtrlIoGetDeferStatsSupported)
   299 		if (CtrlIoGetDeferStatsSupported)
   301 			{
   300 			{
   302 			test.Printf(_L("\nTotals: Avg %2d %d%% CC=%4d \n"), fullTot/fullcCount, (TInt)(totChangeCount*100)/fullcCount, totChangeCount);
   301 			test.Printf(_L("\nTotals: Avg %2d %d%% CC=%4d \n"), fullTot/fullcCount, (TInt)(totChangeCount*100)/fullcCount, totChangeCount);
   303 			test.Printf(_L("PG %d PO %d(%d%%) NG %d NO %d\n"),pageGarbageCount,  pageOtherCount,(TInt) (pageOtherCount*100/fullcCount), normalGarbageCount,  normalOtherCount );
   302 			test.Printf(_L("PG %d PO %d(%d%%) NG %d NO %d\n"),pageGarbageCount,  pageOtherCount,(TInt) (pageOtherCount*100/fullcCount), normalGarbageCount,  normalOtherCount );
       
   303 			test(pageOtherCount > 0);	// Ensure at least one paging conflict occurred during the test.
   304 			}
   304 			}
   305 
   305 
   306 		// If totChangeCount does not change, nand maybe busy waiting.
   306 		// If totChangeCount does not change, nand maybe busy waiting.
   307 		test(totChangeCount>0);
   307 		test(totChangeCount>0);
   308 		}	// while ()
   308 		}	// while ()
   509 	{	
   509 	{	
   510 	TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress();
   510 	TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress();
   511 	TUint8* start = (TUint8*)romHeader+romHeader->iPageableRomStart;
   511 	TUint8* start = (TUint8*)romHeader+romHeader->iPageableRomStart;
   512 	TUint size = romHeader->iPageableRomSize;
   512 	TUint size = romHeader->iPageableRomSize;
   513 	TUint8* addr=NULL;
   513 	TUint8* addr=NULL;
   514 	TBool flush;
       
   515 	while (Testing)
   514 	while (Testing)
   516 		{
   515 		{
   517 			PageSemaphore.Wait(); // wait for main thread to want paging.
   516 			PageSemaphore.Wait(); // wait for main thread to want paging.
   518 			flush = (PagesBeingPaged==0);
       
   519 			addr=start+((TInt64(Random())*TInt64(size))>>32);	
   517 			addr=start+((TInt64(Random())*TInt64(size))>>32);	
   520 			PageDoneSemaphore.Signal(); // Acknolage request.
   518 			PageDoneSemaphore.Signal(); // Acknowledge request.
   521 
   519 
   522 			PageMutex.Wait();
   520 			PageMutex.Wait();
       
   521 			TBool flush = (PagesBeingPaged==0);	// Ensure only one thread is flushing the cache at a time.
   523 			PagesBeingPaged++;
   522 			PagesBeingPaged++;
   524 			PageMutex.Signal();
   523 			PageMutex.Signal();
   525 
   524 
   526 			if (flush)
   525 			if (flush)
   527 				UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0);
   526 				UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0);