1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/memmodel/epoc/flexible/mmu/mthrash.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,78 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +
1.20 +
1.21 +/**
1.22 + @file
1.23 + @internalComponent
1.24 +*/
1.25 +
1.26 +#ifndef MTHRASH_H
1.27 +#define MTHRASH_H
1.28 +
1.29 +class DThrashMonitor
1.30 + {
1.31 +public:
1.32 +
1.33 + DThrashMonitor();
1.34 + void Start();
1.35 + TInt ThrashLevel();
1.36 + TInt SetThresholds(TUint thrashing, TUint good);
1.37 +
1.38 + void NotifyStartPaging(); // The current thread has started a paging operation
1.39 + void NotifyEndPaging(); // The current thread has completed a paging operation
1.40 +
1.41 +private:
1.42 +
1.43 + enum TCount
1.44 + {
1.45 + ECountThreadsPaging,
1.46 + EMaxCount
1.47 + };
1.48 +
1.49 + struct TCountData
1.50 + {
1.51 + TInt iCount; // Current value of counter
1.52 + TUint32 iLastUpdateTime; // Time counter was last updated
1.53 + TInt64 iTotal; // Accumulator for ticks * value
1.54 + TInt iAverage; // Average value of counter for last time period * 100
1.55 + };
1.56 +
1.57 +private:
1.58 +
1.59 + void UpdateCount(TCount aCount, TInt aDelta);
1.60 + void RecalculateThrashLevel(); // Update internal state, called periodically from timer DFC
1.61 + static void UpdateDfcFunc(TAny* aPtr);
1.62 +
1.63 +private:
1.64 +
1.65 + TBool iRunning;
1.66 + NTimer iUpdateTimer;
1.67 + TDfc iUpdateDfc;
1.68 + TUint32 iLastUpdateTime;
1.69 + NFastMutex iMutex;
1.70 +
1.71 + TInt iThrashLevel;
1.72 + TBool iIsThrashing;
1.73 + TInt iThresholdThrashing;
1.74 + TInt iThresholdGood;
1.75 +
1.76 + TCountData iCount[EMaxCount];
1.77 + };
1.78 +
1.79 +extern DThrashMonitor TheThrashMonitor;
1.80 +
1.81 +#endif