On Thu, 2007-Jan-18 23:22:01 +0100, Ivan Voras wrote: >I'm thinking of doing something which would require streaming large >amounts of pretty much real-time data from kernel to a userland >application (for further processing).
The simplest interface is read(). The downside is that (in the default case), you need to do a copyout() of the data. My suggestion is mmap(): Userland mmap()'s a large buffer and your kernel app treats it as a ring buffer and generated data directly into it. The trick here is informing userland when data is available and how much there is. The approach I've used is to store the kernel write pointer (and optionally, the userland read pointer) in mmap()'d memory as well. Userland can block (to wait for the kernel to provide more data) in various ways: - If there's no data to process, sleep for a convenient period and check again. This needs no support from your kernel driver. - Use kqueue(), signal() or read() a token to indicate when some amount of data is available. -- Peter Jeremy
pgpT7s0FgYrbQ.pgp
Description: PGP signature