Kernel module/IPC with userland: create and write to FIFO

Daniel O'Connor doconnor at gsoft.com.au
Fri Jun 17 14:26:31 GMT 2005


On Fri, 17 Jun 2005 23:47, Hannes Mayer wrote:
> > If you read and write to it, it acts like a FIFO.
>
> Thanks for your reply! :-)
>
> Well, the reason why I want to use a true FIFO is, that data is
> sampled i.e. every second and I want to write it to disk in userspace
> only every minute or so. So if I add a ".d_ioctl" to "struct cdevsw"

I wasn't suggesting an ioctl(), just read().

> for the device node, I have to make a function in the kernel module
> for handling the userspace read request and I have to cache the
> sampled data in the kernel module. I want the module to be flexible,

The read() function is really quite simple, as for the caching - that can be 
done in userland.

> so if I don't sample at a fixed frequency (i.e. event counting) I
> don't know how much data is coming in in a certain time interval and
> with a FIFO  I don't have to care about the data-cache size.

I would suggest that you buffer it in userland.

Ie have a small buffer in the kernel and have a userland process that reads 
from the kernel as soon as data is ready and stores it in memory. 

Doing it this way makes it much simpler to modify your write strategy as you 
need to.

It doesn't matter what the variability of the data rate is if you use 
read/write since the userland app will spend 99% of it's time waiting in 
select() for the kernel to tell it when new data is available.

-- 
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20050617/e29c8850/attachment.bin


More information about the freebsd-stable mailing list