Nelson Castillo wrote:
On 8/9/07, hinko.kocevar@xxxxxxxxxxxx <hinko.kocevar@xxxxxxxxxxxx> wrote:
is there
a way for the module to notify an application of some
event happening?
By using select/poll from the userspace one needs to implement similar
procedure in their (character) device driver as well - namely poll().
This would (if properly implemented) relieve you of the need to manually
check for an event to happen. See LDD3 (http://lwn.net/Kernel/LDD3/) for
sample device driver that utilizes the poll() syscall.
Isn't blocking reads also useful in this case?
I would also make read calls block when there is no data available.
It depends what the requirements of the user are. I've understood that
he wanted to issue eg. a read() when data was available, not needing to
periodically poll or test for data. Select would provide just that with
the ability to do 'other stuff' if no data is available. If using
blocking read (in single threaded application) this could block forever
- while combination of select (probably with timeout, or no timeout at
all) would nicely circumvent that case. Another thing would be using
non-blocking reads but with little more work on the user side.
Well, this plays nice with threads.
True.
I haven't needed select/pool yet. But in a single thread (perhaps with
timeouts) select/pool seems better.
(I'm no expert, but I'd like to know what you think)
No expert here either;), but in single threaded application I found out
that select/poll plays nice with blocking read/write calls, if there is
no data to be read/written at the moment. In multi threaded application
the use of select (for this kind of simple operation) might not be
required - but again it all depends on the nature of the desired operation.
Regards,
Hinko
--
ČETRTA POT, d.o.o., Kranj
Planina 3
4000 Kranj
Slovenia, Europe
Tel. +386 (0) 4 280 66 03
E-mail: hinko.kocevar@xxxxxxxxxxxx
Http: www.cetrtapot.si
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ