Question about timers and timeouts

Discussion in 'Windows Vista Drivers' started by Peter, Aug 11, 2003.

  1. Peter

    Peter Guest

    Hi,

    I red some mails in this group and some other articles about timers in NT.
    The smallest period distinguishable by NT system for KeSetTimerEx
    is 10miliseconds - depending on motherboard clocks. (If I am not mistaken)

    I have two questions:
    1. Consider KeSetTimer function (not KeSetTimerEx to avoid confusing)
    Second parameter is DueTime - timeout in 100 of nanoseconds.
    What is the smallest (but really setable) timeout ?
    Which clocks (or mechanism) NT uses for counting so smalest timeouts ?

    2. When I need timer with smaller period than 10 miliseconds,
    can not be used repeatedly called KeSetTimer with timeout smaller than 10
    miliseconds
    this way:

    KeInitializeTimer(..... //initialization
    KeInitializeDPC(..... //init DPC
    KeSetTimer(.... DPCRoutine) //first setting of timeout smaller
    than 10 miliseconds


    DPCRoutine
    {
    Some actions...

    KeSetTimer(.... //setting of timeout smallest than 10
    miliseconds again
    }

    ???

    Thanks !
    Peter
     
    Peter, Aug 11, 2003
    #1
    1. Advertisements

  2. Peter

    Nick Ryan Guest

    The standard clock interrupt frequency is 60 times a second (apparently
    somewhat configurable via the ExSetTimerResolution API), and this will
    limit the granularity of any timing/scheduling/waiting operation you
    attempt under Windows. There are two exceptions:

    1. The hardware may support a higher-resolution timer; in kernel-mode,
    you can see if it does by making use of the KeQueryPerformanceCounter
    API (visible in user-mode as
    QueryPerformanceCounter/QueryPerformanceFrequency).

    2. On most Intel-compatible CPUs you can directly make use of the RTDSC
    instruction as an extremely-high-frequency counter.
     
    Nick Ryan, Aug 11, 2003
    #2
    1. Advertisements

  3. Second parameter is DueTime - timeout in 100 of nanoseconds.
    1 hardware timer tick.
    NT relies on HAL to work with timer hardware. Usual PC has 2 timers - IRQ0 and
    the RTC chip, and the HAL exposes them to the rest of the kernel as 2 timers -
    dispatcher timer and profiling timer. What hardware is used for what timer is
    HAL-dependent.
    ExSetTimerResolution will give you timer precision up to 1ms. Lower values are
    impossible. You can measure time in more accurate way, but you cannot wait this
    way.
     
    Maxim S. Shatskih, Aug 11, 2003
    #3
  4. The standard clock interrupt frequency is 60 times a second (apparently

    100 times a second on modern NTs.
     
    Maxim S. Shatskih, Aug 11, 2003
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.