mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-08 03:27:04 +09:00
do not wait 1 msec in suspension.
This commit is contained in:
parent
329ac704f9
commit
cc59888b35
1 changed files with 29 additions and 0 deletions
|
@ -3252,6 +3252,35 @@ COR_PRF_SUSPEND_REASON GCSuspendReasonToProfSuspendReason(ThreadSuspend::SUSPEND
|
|||
}
|
||||
#endif // PROFILING_SUPPORTED
|
||||
|
||||
// exponential spinwait with an approximate time limit for waiting in microsecond range.
|
||||
// when iteration == -1, only usecLimit is used
|
||||
void SpinWait(int iteration, int usecLimit)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
QueryPerformanceCounter(&li);
|
||||
int64_t startTicks = li.QuadPart;
|
||||
|
||||
QueryPerformanceFrequency(&li);
|
||||
int64_t ticksPerSecond = li.QuadPart;
|
||||
int64_t endTicks = startTicks + (usecLimit * ticksPerSecond) / 1000000;
|
||||
|
||||
int l = min((unsigned)iteration, 30);
|
||||
for (int i = 0; i < l; i++)
|
||||
{
|
||||
for (int j = 0; j < (1 << i); j++)
|
||||
{
|
||||
System_YieldProcessor();
|
||||
}
|
||||
|
||||
QueryPerformanceCounter(&li);
|
||||
int64_t currentTicks = li.QuadPart;
|
||||
if (currentTicks > endTicks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//************************************************************************************
|
||||
//
|
||||
// SuspendRuntime is responsible for ensuring that all managed threads reach a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue