Question : poll_wait()

sir ,
below i wrote some code related to poll implementation in linux device drivers found in oreilly publications "linux device drivers " book .
************************
 unsigned int scull_p_poll(struct file *filp ,
                  poll_table *wait)
 
    {
          int mask ;
  poll_wait(filp,&wait_queue1 ,wait);
  poll_wait(filp ,&wait_queue2 ,wait);


 if(readable) mask|=POLLIN | POLLRDNORM;
 if(writable)
            mask|=POLLOUT | POLLWRNORM;
 
**********************************

poll method is used to check whether a operation will succed before actually calling it .


So , what is the need for poll_wait() ? .
we have to check only condition for readability or writability and return corresponding mask .


Answer : poll_wait()

The short answer is that it's just necessary for the xxpoll() routine to add to one or more wait queues so that it can be awakened when I/O is ready. The kernel can't do this before calling xxpoll() because only the driver knows how to access the queues.

It looks like you have an old edition of this book. The Third Edition, available freely online at:

   http://www.oreilly.com/catalog/linuxdrive3/book/

has a lot more detail on the subject.
Random Solutions  
 
programming4us programming4us