Thanks Jan That makes it clearer for me, poll_wait does not put the process to sleep, it just adds the process to the wait queue, and depending on what the poll method of the devie returns, kernel puts the process to sleep or informs the process that data is available to be read etc. But what happens when there is data on the fd. i.e a user process had done a select on the fd, the select call in tunr called the poll method of the device, which returned saying there was no data. SInce there was a timeout specified in select, the process was pu to sleep. Now, two things might happen, either the data arrives on the fd(considering it is a read fd), or timeout happened. So how is process awakened when there is data on the fd before timeout. So here, does the process that writes something to the fd call wake_up_interruptible and then the select call for our original(reading) process return ? Here, what if there is no second process, one process is trying to read from an fd, and that fd has a read buffer in the kernel, and some other module function itself writes on that buffer, so here it should be responsibility of this module function to call wake_up_interruptible, right ? Well, I tried reading rubini once to clear things up but since i have doubts, i though this was the best place to clear them. thanks Amit Jan Hudec <bulb@ucw.cz>@nl.linux.org on 06/10/2004 03:57:25 AM Sent by: kernelnewbies-bounce@nl.linux.org To: Tyler <tyler@agat.net> cc: kernelnewbies@nl.linux.org Subject: Re: poll device function On Wed, Jun 09, 2004 at 21:52:48 +0200, Tyler wrote: > aksingh@hss.hns.com wrote: > > > > > > > >Hi, > > > > I am implementing a poll function for my char device, there is a standard > >procedure of doing it, > > > >1. poll_wait(give yr wait_queues address here); > > > >2. then see if there is something to be read/write, set a mask and return > >to user. > > > >but here drivers dont seem to add the current process to the waitqueue, > >before calling poll_wait, so does poll_wait does this for them ? > > > >regards > >Amit > > > yes exactly. poll_wait adds a wait queue in the pollwait table of the > kernel. When an event occurs (write of data for example), the process is > awaken. It's not that exact. The original poster seems to assume, that poll_wait sleeps. But it does not. It just gathers the waitqueues. And only when ->poll methods of all watched descriptors have been called, and said they don't have events, only then the process is put to sleep on all those queues at once. ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz>
Attachment:
signature.asc
Description: Binary data