kernel/eka/memmodel/epoc/flexible/mmu/mthrash.h
changeset 9 96e5fb8b040d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #ifndef MTHRASH_H
       
    24 #define MTHRASH_H
       
    25 
       
    26 class DThrashMonitor
       
    27 	{
       
    28 public:
       
    29 	
       
    30 	DThrashMonitor();
       
    31 	void Start();
       
    32 	TInt ThrashLevel();
       
    33 	TInt SetThresholds(TUint thrashing, TUint good);
       
    34 
       
    35 	void NotifyStartPaging();  			// The current thread has started a paging operation
       
    36 	void NotifyEndPaging();    			// The current thread has completed a paging operation
       
    37 
       
    38 private:
       
    39 
       
    40 	enum TCount
       
    41 		{
       
    42 		ECountThreadsPaging,
       
    43 		EMaxCount
       
    44 		};
       
    45 
       
    46 	struct TCountData
       
    47 		{
       
    48 		TInt iCount;					// Current value of counter
       
    49 		TUint32 iLastUpdateTime;		// Time counter was last updated
       
    50 		TInt64 iTotal;					// Accumulator for ticks * value
       
    51 		TInt iAverage;					// Average value of counter for last time period * 100
       
    52 		};
       
    53 
       
    54 private: 
       
    55 
       
    56 	void UpdateCount(TCount aCount, TInt aDelta);	
       
    57 	void RecalculateThrashLevel();		// Update internal state, called periodically from timer DFC
       
    58 	static void UpdateDfcFunc(TAny* aPtr);
       
    59 
       
    60 private:
       
    61 
       
    62 	TBool iRunning;
       
    63 	NTimer iUpdateTimer;
       
    64 	TDfc iUpdateDfc;
       
    65 	TUint32 iLastUpdateTime;
       
    66 	NFastMutex iMutex;
       
    67 
       
    68 	TInt iThrashLevel;
       
    69 	TBool iIsThrashing;
       
    70 	TInt iThresholdThrashing;
       
    71 	TInt iThresholdGood;
       
    72 
       
    73 	TCountData iCount[EMaxCount];
       
    74 	};
       
    75 
       
    76 extern DThrashMonitor TheThrashMonitor;
       
    77 
       
    78 #endif