H
Harsha_MR
Guest
No matter what value I specify for s_cpu_budget(1, 5, 10 , 12, 15), the loop breaks up only after 15.625 msec.
The next number for s_cpu_budget is 30 where I can see the change, In between 15 to 30 there is no impact.
Does it work at the multiples of 15..? What change I have to make for this logic to break at 10msec...?
int s_cpu_budget = 15;
FILETIME ft1, ft2, ft3, current_time, start_time;
ULARGE_INTEGER current_time_int, start_time_int;
const unsigned int FT_TO_MS = 10000;
GetProcessTimes(GetCurrentProcess(), &ft1, &ft2, &ft3, &start_time);
start_time_int.HighPart = start_time.dwHighDateTime;
start_time_int.LowPart = start_time.dwLowDateTime;
Sleep(s_cpu_budget);
while (true)
{
GetProcessTimes(GetCurrentProcess(), &ft1, &ft2, &ft3, ¤t_time);
current_time_int.HighPart = current_time.dwHighDateTime;
current_time_int.LowPart = current_time.dwLowDateTime;
if (((current_time_int.QuadPart - start_time_int.QuadPart) / FT_TO_MS) >= s_cpu_budget)
break; // Breaks only after 15.625 msec
Sleep(1);
}
Continue reading...
The next number for s_cpu_budget is 30 where I can see the change, In between 15 to 30 there is no impact.
Does it work at the multiples of 15..? What change I have to make for this logic to break at 10msec...?
int s_cpu_budget = 15;
FILETIME ft1, ft2, ft3, current_time, start_time;
ULARGE_INTEGER current_time_int, start_time_int;
const unsigned int FT_TO_MS = 10000;
GetProcessTimes(GetCurrentProcess(), &ft1, &ft2, &ft3, &start_time);
start_time_int.HighPart = start_time.dwHighDateTime;
start_time_int.LowPart = start_time.dwLowDateTime;
Sleep(s_cpu_budget);
while (true)
{
GetProcessTimes(GetCurrentProcess(), &ft1, &ft2, &ft3, ¤t_time);
current_time_int.HighPart = current_time.dwHighDateTime;
current_time_int.LowPart = current_time.dwLowDateTime;
if (((current_time_int.QuadPart - start_time_int.QuadPart) / FT_TO_MS) >= s_cpu_budget)
break; // Breaks only after 15.625 msec
Sleep(1);
}
Continue reading...