Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can stick to your design. You only need to set the system interrupt frequency to run at its maximum frequency. In order to obtain this, you just have to execute the following code anywhere in your code:</p> <pre><code>#define TARGET_RESOLUTION 1 // 1-millisecond target resolution TIMECAPS tc; UINT wTimerRes; if (timeGetDevCaps(&amp;tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) { // Error; application can't continue. } wTimerRes = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax); timeBeginPeriod(wTimerRes); </code></pre> <p>This will force the systems interrupt period to run at maximum frequency. It is a system wide behavior, thus it may even be done in a separate process. Don't forget to use</p> <pre><code>MMRESULT timeEndPeriod(wTimerRes ); </code></pre> <p>when done to release the resource and reset the interrupt period to default. See <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd743609%28v=vs.85%29.aspx" rel="nofollow noreferrer">Multimedia Timers</a> for details.</p> <p><em>You must match each call to <code>timeBeginPeriod</code> with a call to <code>timeEndPeriod</code>, specifying the same minimum resolution in both calls. An application can make multiple <code>timeBeginPeriod</code> calls as long as each call is matched with a call to <code>timeEndPeriod</code>.</em></p> <p>As a consequence, all timers (including your current design) will operate at higher frequency since the granularity of the timers will improve. A granularity of 1&nbsp;ms can be obtained on most hardware.</p> <p>Here is a list of <em>interrupt periods</em> obtained with various settings of <code>wTimerRes</code> for two different hardware setups (A+B):</p> <p><img src="https://i.stack.imgur.com/AOa1L.jpg" alt="ActualResolution (interrupt period) vs. setting of wTimerRes"></p> <p>It can easily be seen that the 1&nbsp;ms is a theoretical value. ActualResolution is given in 100&nbsp;ns units. 9,766 represents 0.9766&nbsp;ms which is 1024 interrupts per second. (In fact it should be 0.9765625 which would be 9,7656.25 100&nbsp;ns units, but that accuracy obviously does not fit into an integer and is therefore rounded by the system.)</p> <p>It also becomes obvious that i.g. platform A does not really support all the range of periods returned by <code>timeGetDevCaps</code> (values ranging between <code>wPeriodMin</code>and <code>wPeriodMin</code>).</p> <p><strong>Summary:</strong> The multimedia timer interface can be used to modify the interrupt frequency <em>system wide</em>. As a consequence all timers will change their granularity. Also the system time update will change accordingly, it will increment more often and in smaller steps. <strong>But:</strong> The actual behavior depends on the underlaying hardware. This hardware dependency has gotten a lot smaller since the introduction of Windows&nbsp;7 and Windows&nbsp;8 since newer schemes for timing have been introduced. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload