Thanks Jan, So the only different thing my function does from wait_event_interruptible is that it does not check for a signal pending for the current process, right ? So yes correct i must use wait_event_interruptible. Amit Jan Hudec <bulb@ucw.cz>@vagabond.light.src> on 06/08/2004 06:20:15 PM Sent by: Jan Hudec <bulb@vagabond.light.src> To: Amit Kumar Singh/HSS@HSS cc: Subject: Re: schedule() On Tue, Jun 08, 2004 at 15:53:36 +0530, aksingh@hss.hns.com wrote: > > > > > Hi, > > This is the way I intend to block the read call on my char device, if > there is no data to be read. > > void block() { > DECLARE_WAITQUEUE(w, current); > __add_wait_queue(&some_wait_queue, &w); > current->state=TASK_INTERRUPTIBLE; > if (!isready()) > schedule(); > current->state=TASK_RUNNING; > remove_wait_queue(&some_wait_queue, &w); > } Oh, and now I noticed you sleed in TASK_INTERRUPTIBLE state and don't check for signals. Now, THAT is a BUG! You should do: void block() { int ret = 0; wait_event_interruptible(some_wait_queue, isready(), ret); return ret; /* Will be -ERESTARTSYS if you wake up due tu signal */ } ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz>
Attachment:
signature.asc
Description: Binary data