Chetan Nanda wrote:
On Thu, Aug 13, 2009 at 6:30 PM, Shankar Ganesh
<shankarganeshk@xxxxxxxxx <mailto:shankarganeshk@xxxxxxxxx>> wrote:
On Thu, Aug 13, 2009 at 5:23 PM, Daniel Baluta
<daniel.baluta@xxxxxxxxx <mailto:daniel.baluta@xxxxxxxxx>> wrote:
On Thu, Aug 13, 2009 at 2:17 PM, Shankar
Ganesh<shankarganeshk@xxxxxxxxx
<mailto:shankarganeshk@xxxxxxxxx>> wrote:
> Hi ,
>
> I have a doubt regarding poll function in char driver . Let
us consider
> following code
>
>
--------------------------------------------------------------------------------------
> static unsigned int random_poll(struct file *file,
poll_table * wait)
> {
> unsigned int mask;
> poll_wait(file, &random_read_wait, wait);
> poll_wait(file, &random_write_wait, wait);
> mask = 0;
> ........
> return mask;
> }
>
>
> read() / write()
> {
> wait_event_interuptable()
> }
>
--------------------------------------------------------------------------------------
>
> Does the above code (poll function) is in sleep state until both
> random_read_wait & random_write_wait are awakened ? . If i
have use case If
> i want my user space application to poll only for read ,
then can i remove
> one of the above ?
t beautiful thing we can experience is the mysterious. It is the
> source of all true art and science."
>
AFAIK your actual random_poll function nevers sleeps. The
calls for
poll_wait just inform the VFS layer
about the existence of random_read_wait and random_write_wait wait
queues. An upper layer will use the return mask
to actual put your current process to sleep if there are no data
available for reading/writing.
Thanks. How do VFS know which of the queue is woke-up (read -WQ or
write - WQ ) ? . As any ISR or relevant function wil wake-up the
wait-queue.
It is decided by value return by drivers poll function. e.g. if driver
detects that device is ready for reading then poll function should
return 'POLLRDNORM' to VFS layer. Similarly 'POLLWRNORM' for writable
case.
Thanks Chetan .
Return Value - POLLRDNORM & POLLWRNORM describes the operations that
could be immediately performed without blocking. I would like to know
the case where there is blocking
I think you should not care about what type of operation a
user space
application is watching for.
Daniel.
--
With Regards,
ShankarGanesh K .
Thanks,
Chetan Nanda
"The most beautiful thing we can experience is the mysterious. It
is the source of all true art and science."
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ