[lkml]   [2001]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectIRQ and sleep_on
    I've missed the thread "avoiding bad sleeps" last week. I've had a similar problem and I would like to discuss the solution I've used to avoid it.

    I want to wake up a sleeping process from an IRQ handler. In the process, if I use a interruptible_sleep_on(), I need first to restore flags (otherwise the process will sleep forever).

    // <<== here IRQ handler possibly call wake_up()

    If I first enable interrupts and then call sleep_on, sometimes (often) the wake_up is called (due to a pending interrupt) when the wait_queue is empty.
    I've written a modified version of interruptible_sleep_on which takes an additionnal argument : flags to be restored.

    my_interruptible_sleep_on(&my_queue, flags);

    It seems to be ok. I've no more bad sleeps or more exactly rarely and that why I submit this to you. Is my way to do it correct ?
    I've joined at the end of this mail the modified function.

    Christophe Barbé

    long my_interruptible_sleep_on_timeout(struct wait_queue **p, long timeout, unsigned long oflags)
    unsigned long flags;
    struct wait_queue wait;

    current->state = TASK_INTERRUPTIBLE;

    wait.task = current;
    __add_wait_queue(p, &wait);

    timeout = schedule_timeout(timeout);

    __remove_wait_queue(p, &wait);

    return timeout;

    Christophe Barbé
    Software Engineer
    Lineo High Availability Group
    42-46, rue Médéric
    92110 Clichy - France
    phone (33).
    fax (33).
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 12:55    [W:0.023 / U:15.824 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site