-   Linux - Kernel (
-   -   Polling on device file (

AnkurTank 10-09-2012 12: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 12: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.

All times are GMT -5. The time now is 07:17 PM.