[PATCH v2] Cygwin: Minor updates to load average calculations
Mark Geisert
mark@maxrnd.com
Thu Nov 21 10:52:00 GMT 2024
On 11/21/2024 1:34 AM, Corinna Vinschen wrote:
> On Nov 21 01:12, Mark Geisert wrote:
>> Hi Corinna,
>>
>> On 11/18/2024 4:22 AM, Corinna Vinschen wrote:
>>> Hi Mark,
>>>
>>>
>>> Jon, would you mind to take a look, please?
>>
>> I appreciate the additional eyes, thanks.
>>
>>> This looks good to me, just one question...
>>>
>>> On Nov 12 22:03, Mark Geisert wrote:
>> [...]
>>>> + /* Delay a short time so PdhCQD in caller will have data to collect */
>>>> + Sleep (16/*ms*/); /* let other procs run; one|more yield()s not enough */
>>>
>>> Is there a reason you specificially chose 16 msecs here?
>>>
>>> I'm asking because the usual clock tick is roughly 15.x msecs.
>>> Any Sleep() > 0 but < 16 results in a sleep of a single clock tick, i.e.,
>>> 15 ms. Occassionally 2 ticks, ~31 msecs, 1 to 5 out of 100 runs.
>>>
>>> If you choose a value of 15 msecs, the probability of a Sleep() taking
>>> two ticks is much higher and can be 1 out of 2 Sleep().
>> ^^^^^^
>> lower, I think
>
> No, higher. In a low load scenario
>
> Sleep (1) --> < 5% will take two or more clock ticks
> Sleep (15) --> up to 50 % will take two or more clock ticks
> Sleep (16) --> 100% will take two or more clock ticks
Ah, now I see what you mean. So to maximize the probability it's only
one tick, use "Sleep(1)". Still that's not a guarantee it's one tick.
Have I got that right?
Thanks,
..mark
More information about the Cygwin-patches
mailing list