What exactly does the msWindowLength parameter to SetThreadpoolTimer mean?


A customer was looking for clarification on the msWindow­Length parameter to the Set­Threadpool­Timer function.

msWindowLength [in, optional]

The maximum amount of time the system can delay before calling the timer callback. If this parameter is set, the system can batch calls to conserve power.

"It's not clear whether the window extends both before and after the due time (presumably, half the window size on either side), or whether the timer will always delay at least until the due time, and possibly up to the due time plus the window value."

The window specifies the maximum delay, and generally speaking, delay means late, never early. (When was the last time you heard that your flight was delayed, by which they meant that it landed 30 minutues early?)

In other words, the latter interpretation is the correct one. The threadpool will schedule the callback at some point between the due time and the due time plus the window.

(For the record, the Set­Coalescable­Timer and Set­Waitable­Timer­Ex functions work the same way.)

The customer thanked us for the clarification. That's what they thought, but they wanted to make sure.

Comments (5)
  1. Yukkuri says:

    Using the word “Window” in the name suggests the opposite, so I can understand why they wanted to check that ‘delay’ in fact was being used to mean ‘delay’.

    ‘And only one for birthday presents, you know. There’s glory for you!’
    ‘I don’t know what you mean by “glory”,’ Alice said.
    Humpty Dumpty smiled contemptuously. ‘Of course you don’t — till I tell you. I meant “there’s a nice knock-down argument for you!”‘
    ‘But “glory” doesn’t mean “a nice knock-down argument”,’ Alice objected.
    ‘When I use a word,’ Humpty Dumpty said, in rather a scornful tone, ‘it means just what I choose it to mean — neither more nor less.’
    ‘The question is,’ said Alice, ‘whether you can make words mean so many different things.’
    ‘The question is,’ said Humpty Dumpty, ‘which is to be master — that’s all.’

    1. ErikF says:

      It seems that the function documentation and parameters were written with kernel-mode glasses on: the window in this case is the window of opportunity that the kernel has to process other business before notifying the callback. My biggest issue with the documentation for this parameter is that it doesn’t specify what units of time are being used here (probably milliseconds like with msPeriod, but who knows?)

      1. Marcos Kirchner says:

        I think the ms part in the parameter name hints at millisecond, but explicit calling it out wouldn’t be bad.

  2. alegr1 says:

    Actually, KeSetCoalescableTimer allows the callback to happen at the target time plus/minus TolerableDelay. The documentation spells that explicitly.

  3. John Doe says:

    I’ve had managers f̵o̵r̵c̵e̵ 𝑝𝑟𝑒𝑠𝑠𝑢𝑟𝑒 me to request obvious vendor clarifications for… obvious reasons.

Comments are closed.

Skip to main content