title: What is the best way to sample periodicaly gpio-pins in Linux?
body: <p>I like to sample a signal which is generated by the pins of my Raspberry Pi. I made the experience that high sample rates are difficult to realize.</p>
  
  <p>First I done a fast approach with Python(super slow). Then I changed to ANSI C + the bcm2835.h lib. I gained significant performance gains.</p>
  
  <p>Now I am asking my self the question: How to do the best sampling under Linux?</p>
  
  <p>My tries were undertaken in user space. But what is about, switching to kernel space? I can write a simple character device kernel module. In this module the pins are periodically checked. If the state changed some information is put into a buffer. This i/o buffer is polled by a synchronous file read for a application in user space. The best solution for me would be, if the pin checking can be done with a fixed frequency(sample period should be constant for signal processing).</p>
  
  <p>The set up for this could be:</p>
  
  <p>@kernel: character module + kernel thread + gpio device tree interface + DSP at constant sampling time</p>
  
  <p>@user space: i/o app reading synchronous from character module</p>
  
  <p>Ideas/tips?</p>