On Wed, Dec 07, 2005 at 20:45:16 +0530, T.Krishnanand wrote: > Hi, > > 1) whats the difference between wait_event_interruptible and > wait_for_completion_interruptible ? They operate on different objects that have different semantics. wait_event sleeps until a wait_queue is awoken (by wake_up) and then checks a condition -- which can be arbitrary -- and goes back to sleep if it's false. wake_up wakes up _all_ processes on that wait_queue. The condition is checked so that you can not miss the wake up (assured by careful ordering). wait_for_completion waits on completion, which is basically a semaphore. One complete will wake up one wait_for_completion. Wait for completion does not check any additional conditions. > 2) When is one used in favour of the other ? It depends on how the condition you are waiting for looks. There is one special case - completions are the only reliable way to wait for kernel thread exit, because they provide the complete_and_exit() call. When you are unloading a module that ran a kernel thread, you must make sure it no longer executes your code before you unload and complete_and_exit() is the only way to be really sure. > 3) Why "might_sleep" check is ONLY for "completion" kind of sleep > routines but not for "wait" kind of sleep routines ? Don't know. But since wait_event is a macro, it should really be checked in schedule I think. -- Jan 'Bulb' Hudec <bulb@xxxxxx>
Attachment:
signature.asc
Description: Digital signature