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

From: Daniel O'Connor (doconnor_at_gsoft.com.au)
Date: 06/17/05

  • Next message: David Sze: "Re: FreeBSD MySQL still WAY slower than Linux"
    To: Hannes Mayer <debiandude@gmail.com>
    Date: Fri, 17 Jun 2005 23:56:05 +0930
    
    
    

    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 message: David Sze: "Re: FreeBSD MySQL still WAY slower than Linux"

    Relevant Pages

    • Re: "Streaming" data from kernel to userland
      ... interface which could be used to transfer large amounts of constantly ... generated data from kernel to a userland application? ... for Genesis Software - http://www.gsoft.com.au ...
      (freebsd-hackers)
    • Re: Attempted summary of "RT patch acceptance" thread
      ... tries to keep the userland API as close as possible to the non-RT one, ... by increasing the kernel complexity with relative slowdown. ... RTAI quickly becomes useless (ok it can run nanosleep with fusion fine, ... RTAI/rtlinux as the only hard-RT with guaranteed deadline. ...
      (Linux-Kernel)
    • Re: [RFC] Splitting kernel headers and deprecating __KERNEL__
      ... >> two parties on an ABI doesn't imply that one party gets to define it ... imposition, kernel developers won't care. ... because there's a contract with userland that they don't want to ... change in the copy/extract/whatever of kernel headers that userland is ...
      (Linux-Kernel)
    • Re: "Enhanced" MD code avaible for review
      ... be required to make this work correctly using a userland approach. ... > kernel, and having to try harder to crash the kernel. ... protected *sooner* if the system crashes. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH] remove net driver ugliness that sparse complains about
      ... and when it points to kernel space. ... userland ones. ... and userland pointers, and set_fsis not enough to handle that. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)