[NTOSKRNL::CC] Implement CcOkToAddWriteBehindThread
This commit is contained in:
parent
e75a2adeec
commit
3ae19eaf01
@ -13,6 +13,95 @@
|
|||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
||||||
|
/* Move Typedef Later to cctypes.hpp */
|
||||||
|
typedef struct _WRITE_BEHIND_THROUGHPUT
|
||||||
|
{
|
||||||
|
ULONG PagesYetToWrite;
|
||||||
|
ULONG Throughput;
|
||||||
|
} WRITE_BEHIND_THROUGHPUT, *PWRITE_BEHIND_THROUGHPUT;
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
CcOkToAddWriteBehindThread(VOID)
|
||||||
|
{
|
||||||
|
ULONG ActiveExtraWriteBehindThreads = {0};
|
||||||
|
PWRITE_BEHIND_THROUGHPUT ThroughputStats = nullptr;
|
||||||
|
ULONG PagesYetToWrite = {0};
|
||||||
|
ULONG Throughput = {0};
|
||||||
|
ULONG PreviousThroughput = {0};
|
||||||
|
LONG ThroughputTrend = {0};
|
||||||
|
BOOLEAN Result = false;
|
||||||
|
|
||||||
|
ActiveExtraWriteBehindThreads = CcActiveExtraWriteBehindThreads;
|
||||||
|
ThroughputStats = CcThroughputStats;
|
||||||
|
PagesYetToWrite = CcPagesYetToWrite;
|
||||||
|
|
||||||
|
Throughput = ThroughputStats[ActiveExtraWriteBehindThreads].PagesYetToWrite;
|
||||||
|
PreviousThroughput = 0;
|
||||||
|
|
||||||
|
if (Throughput >= PagesYetToWrite)
|
||||||
|
{
|
||||||
|
Throughput -= PagesYetToWrite;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Throughput = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThroughputStats[ActiveExtraWriteBehindThreads].PagesYetToWrite = PagesYetToWrite;
|
||||||
|
Result = true;
|
||||||
|
|
||||||
|
if (ActiveExtraWriteBehindThreads > 0)
|
||||||
|
{
|
||||||
|
PreviousThroughput = ThroughputStats[ActiveExtraWriteBehindThreads - 1].Throughput;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThroughputStats[ActiveExtraWriteBehindThreads].Throughput = Throughput;
|
||||||
|
|
||||||
|
if (Throughput > 0)
|
||||||
|
{
|
||||||
|
ThroughputTrend = CcThroughputTrend;
|
||||||
|
|
||||||
|
if (Throughput < PreviousThroughput)
|
||||||
|
{
|
||||||
|
if (ThroughputTrend > 0)
|
||||||
|
ThroughputTrend = 0;
|
||||||
|
ThroughputTrend--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ThroughputTrend < 0)
|
||||||
|
ThroughputTrend = 0;
|
||||||
|
ThroughputTrend++;
|
||||||
|
}
|
||||||
|
|
||||||
|
CcThroughputTrend = ThroughputTrend;
|
||||||
|
|
||||||
|
if (ThroughputTrend == 3)
|
||||||
|
{
|
||||||
|
CcThroughputTrend = 0;
|
||||||
|
Result = true;
|
||||||
|
|
||||||
|
if (ActiveExtraWriteBehindThreads < CcMaxExtraWriteBehindThreads)
|
||||||
|
{
|
||||||
|
ThroughputStats[ActiveExtraWriteBehindThreads + 1].Throughput = 0;
|
||||||
|
ThroughputStats[ActiveExtraWriteBehindThreads + 1].PagesYetToWrite = PagesYetToWrite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ThroughputTrend == -3)
|
||||||
|
{
|
||||||
|
CcThroughputTrend = 0;
|
||||||
|
Result = true;
|
||||||
|
|
||||||
|
if (ActiveExtraWriteBehindThreads > 0)
|
||||||
|
{
|
||||||
|
ThroughputStats[ActiveExtraWriteBehindThreads - 1].Throughput = 0;
|
||||||
|
ThroughputStats[ActiveExtraWriteBehindThreads - 1].PagesYetToWrite = PagesYetToWrite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
|
Loading…
Reference in New Issue
Block a user