LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Polling on device file (http://www.linuxquestions.org/questions/linux-kernel-70/polling-on-device-file-4175431254/)

AnkurTank 10-09-2012 01:30 AM

Polling on device file
 
I have one kernel thread(this wont run in calling process context common for all driver instances) created by driver, which signals when asynchronous message is received by it.
An user space application needs to poll for this message.
I have seen sample code for processes waiting on socket descriptors.But i have doubts for following questions.
Is it possible to wait on device file descriptor ?
If such wait can be done how poll will return ? How kernel thread can send an event ?

AnkurTank 10-10-2012 01:28 AM

Got answer
I got answer from Device driver book Ldd3 by Rubini sample code.
scull driver which creates scullpipe has poll implemented.
Now in my case,
User space application poll function call will reach device driver poll function, which can block on queue using poll_wait function call. Kernel thread can write to this queue and poll can be unblocked.
Ldd3 sample code which is compilable in latest kernel version can be found at below path.
https://github.com/martinezjavier/ldd3


All times are GMT -5. The time now is 12:27 AM.