My suggestion is to use the same idea as the linux kernel to capture packets, in particular a packet ring buffer (search: PACKET_RX_RING).
The idea is pretty simple in your custom space program to highlight a ring. Then pass this ring to the โdriverโ (your kernel module), then your driver can simply write data points to the ring, and your user space program can read them. Since this is a ring, you can simply continue to write, and the client can continue to read - if the client is behind, it is likely that your driver can pick up (as soon as he was in the ring), but I am sure that you can size the ring properly.
Each slot in the ring should contain your โserializedโ data, which the user space program can simply read. This type of ring should be easy enough to use locks, and most likely you want your client to hang to see if there is any data.
source share