Date: Fri, 19 Jan 2007 20:08:49 +1100 From: Peter Jeremy <peterjeremy@optushome.com.au> To: Ivan Voras <ivoras@fer.hr> Cc: freebsd-hackers@freebsd.org Subject: Re: "Streaming" data from kernel to userland Message-ID: <20070119090849.GA860@turion.vk2pj.dyndns.org> In-Reply-To: <eoorug$349$1@sea.gmane.org> References: <eoorug$349$1@sea.gmane.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. --=20 Peter Jeremy --TB36FDmn/VVEgNH/ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFFsIqh/opHv/APuIcRAmcfAJ0QVqWutkvgaRmDlNTKBB8LNAyDeQCfX7iL Ujj6NfVKcmuCxgnAeOl2huU= =j5Eg -----END PGP SIGNATURE----- --TB36FDmn/VVEgNH/--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070119090849.GA860>