[lkml]   [2002]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: How to make a kernel thread sleep for a short amount of time?
    I am using high-res timers 
    ( in a driver to do
    sub-millisecond timing for a driver I am developing. With high-res
    timers, I have some code that looks like:

    /* If the state machine asks for a short delay, then shorten
    the timer timeout. */
    if (kcs_result == KCS_CALL_WITH_DELAY) {
    += usec_to_arch_cycles(KCS_SHORT_TIMEOUT_USEC);
    while (kcs_timer.sub_expires >= cycles_per_jiffies) {
    kcs_timer.sub_expires -= cycles_per_jiffies;
    } else {
    kcs_timer.expires += KCS_TIMEOUT_JIFFIES;
    kcs_timer.expires += KCS_TIMEOUT_JIFFIES;

    But the high-res timers are not in the kernel right now, it's a patch
    you have to add, and the user has to have it configured.


    Ben Greear wrote:

    > I am re-working the net/core/pktgen code to be a kernel thread.
    > It is basically working, but I am having trouble making the thread
    > efficiently sleep for durations in the milisecond and micro-second range.
    > I have looked at the udelay and mdelay methods, but they busy
    > wait.
    > I do not need absolute real-time precision, so if I ask the thread
    > to sleep for 100 micro-seconds, it is not a big deal if it does
    > not wake up for 5000us. On average, it should be very close to 100us.
    > I believe the answer may be to use some sort of timer and have my
    > thread sleep on this timer, but I cannot find any examples or
    > documentation on how to do this on the web.
    > If anyone can point me to some example code or documentation, I
    > would appreciate it.
    > Thanks,
    > Ben

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:27    [W:0.022 / U:1.576 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site