scheudler: Cache ThreadData::IsCPUBound() result

This commit is contained in:
Pawel Dziepak 2014-01-16 23:21:10 +01:00
parent b7d404c2df
commit f978518a52
2 changed files with 7 additions and 10 deletions

View File

@ -18,6 +18,7 @@ ThreadData::_InitBase()
fPriorityPenalty = 0;
fAdditionalPenalty = 0;
fEffectivePriority = GetPriority();
fCPUBound = false;
fTimeUsed = 0;
fStolenTime = 0;

View File

@ -50,7 +50,7 @@ public:
inline int32 GetEffectivePriority() const;
inline bool IsCPUBound() const;
inline bool IsCPUBound() const { return fCPUBound; }
inline void CancelPenalty();
inline bool ShouldCancelPenalty() const;
@ -116,6 +116,7 @@ private:
Thread* fThread;
bool fCPUBound;
int32 fPriorityPenalty;
int32 fAdditionalPenalty;
@ -207,21 +208,15 @@ ThreadData::_IncreasePenalty()
int32 oldPenalty = fPriorityPenalty++;
const int kMinimalPriority = _GetMinimalPriority();
if (GetPriority() - oldPenalty <= kMinimalPriority)
if (GetPriority() - oldPenalty <= kMinimalPriority) {
fPriorityPenalty = oldPenalty;
fCPUBound = true;
}
_ComputeEffectivePriority();
}
inline bool
ThreadData::IsCPUBound() const
{
SCHEDULER_ENTER_FUNCTION();
return GetPriority() - fPriorityPenalty == _GetMinimalPriority();
}
inline void
ThreadData::CancelPenalty()
{
@ -229,6 +224,7 @@ ThreadData::CancelPenalty()
int32 oldPenalty = fPriorityPenalty;
fPriorityPenalty = 0;
fCPUBound = false;
if (oldPenalty != 0) {
TRACE("cancelling thread %ld penalty\n", fThread->id);