Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] wait_event_interruptible_timeout not working correctly



Andrew de Quincey writes:
 > 
 > If you look in dvb_frontend_thread(), there is a main loop with the following call:
 > timeout = wait_event_interruptible_timeout(fe->wait_queue,0 != dvb_frontend_is_exiting (fe), delay);
 > 
 > This sleeps for a delay of 3*HZ (initially), or until the frontend thread is told to exit, or the wait queue is woken up.


No, internally it will wake up when the wait queue is woken but
it will go back to sleep (schedule()) if the condition is not met.
See /usr/src/linux/include/linux/sched.h or wait.h (depending on
kernel version)


 > This is the only thing ever waiting on this wait queue.
 > 
 > 
 > In dvb_frontend_ioctl(), there is the following:
 >         if ((cmd == FE_SET_FRONTEND) && (err == 0)) {
 >            // note: cannot use wait_event_interruptible_* here as that
 >            // causes the thread not to wake until AFTER the call here returns. This is useless
 >            // because the whole point is to have the thread wake first, and perform at least one tune
 >            wake_up_interruptible(&fe->wait_queue);
 >            while(fe->state & FESTATE_RETUNE) {
 >               dvb_delay(10);
 >            }
 >         }
 > 
 > This is run during an FE_SET_FRONTEND ioctl. It is supposed to wake the frontend thread from its current sleep 
 > so it can set the frontend. The ioctl code above waits until it signals this has been done by entering a state which 


But it cannot wake up because the condition is not fulfilled.



 > is NOT FESTATE_RETUNE.
 > 
 > The problem is the wake_up_interruptible is not working. The frontend thread *always* sleeps for the 3*HZ. You can 
 > really see this by upping the frontend thread initial delay to 20*HZ. There will be a 20 second delay before the 
 > FE_SET_FRONTEND ioctl returns.
 > 
 > I've tried adding a wake_up_interruptible(&fe->wait_queue) just before the dvb_delay() above, but that doesn't have any effect.
 > 
 > Am I mistaken in thinking the wake_up_interruptible() call is supposed to wake up the tasks on the wait queue before their
 > timeout occurs??


Yes, it will only wake if the condition is fulfilled.

Originally interruptible_sleep_on_timeout() was used here and I am
still using it. The other thing cannot work correctly this way.
If you want to use it you will have to use some extra flag which 
indicates that tuning is needed and check for dvb_frontend_exiting
and (or rather OR) this flag as a wakeup condition.


Ralph



-- 
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index