Re: "Streaming" data from kernel to userland
- From: Peter Jeremy <peterjeremy@xxxxxxxxxxxxxxxx>
- Date: Fri, 19 Jan 2007 20:08:49 +1100
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
Attachment:
pgp3lklUtRDm4.pgp
Description: PGP signature
- References:
- "Streaming" data from kernel to userland
- From: Ivan Voras
- "Streaming" data from kernel to userland
- Prev by Date: Re: "Streaming" data from kernel to userland
- Next by Date: Advice for Stripping the Kernel
- Previous by thread: Re: "Streaming" data from kernel to userland
- Next by thread: Advice for Stripping the Kernel
- Index(es):
Relevant Pages
|
|