Re: Char device. poll() function question.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Wed, Sep 30, 2009 at 6:38 PM, Denis Borisevich <dennisfen@xxxxxxxxx> wrote:
Hi!
I want to use poll() functionality (to properly handle select() and
poll() syscalls) in my char-device driver. The code for my kernel-side
poll() function is (a little bit simplified):

unsigned int my_poll(struct file *filp, struct poll_table_struct *wait)
{
       unsigned int mask=0;
       unsigned long flags;

       poll_wait(filp, my_wait_queue, wait);

       if ( any_data_available > 0)
               mask |= POLLIN | POLLRDNORM;

       return mask;
}

Where "my_wait_queue" is of "wait_queue_head_t" type,
"any_data_available" if the flag which tells if any data is available
within internal buffer.

When you are setting 'any_data_available' variable to some positive values at the same place you have to wakeup process that is waiting in wait-queue.
May be this part is missing in your current code and because of that select is not retuning before timeout.

 
When I load this driver and start user-space application wich calls
select() with 5 seconds timeout the select() returns after waiting
this timeout no matter when the data comes into the port (1,2,3
seconds). The return value is positive when the data available and 0
when no data comes, as it should be. The question is why select()
waits for the timeout even when data is available?

--
Denis

Thanks,
Chetan Nanda
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux