0

I am looking for a mechanism to implement shared objects between kernel and userspace. Useless to say the type but it may probably be char * or char obj[array_size] or void *.

The functionality should enable both the userspace program and kernel to synchronize data in the object. And also need a mechanism in the kernel to alert the userspace program if data is just written to the object in the kernel in a non-blocking way.

I know it seems more like a character device/ or block device driver function but I am working on an embedded system that requires data being shared between userspace and device. I don't know much about the available userspace API for the device's read/write so this way need arises. But I am looking for something like alerting userspace application in ISR or interrupt handler.

I tried finding it on the internet. But I could not get any relevant search results

This is the result of a google search. which totally not what I search for enter image description here

Itchydon
  • 2,572
  • 6
  • 19
  • 33
user786
  • 3,902
  • 4
  • 40
  • 72
  • It’s a character device. Perhaps you want `mmap()` support. Another possibility is to use IOCTL. – 0andriy Mar 27 '21 at 07:25
  • @0andriy you are saying use `mmap` to map objec t(map to object)?Will I be able to write data to that mapped object in ISR? – user786 Mar 27 '21 at 07:28
  • I don’t know the details of your problem and I can’t say anything, that’s why it is just a comment. I would suggest to look at DPDK sources, I believe they do exactly what you want. – 0andriy Mar 27 '21 at 09:09
  • @0andriy i solved the issue. Basically I used wake `wake_up_interruptible` in poll of NAPI in network driver and wait queue. Idea is I want to read packets from NIC card and store in `myobject` in network driver. and in char device I am reading the packets. Can u please guide me if I can copy `struct myobject` to copy_to_user as second argument? – user786 Mar 27 '21 at 09:51
  • 1
    On Stack Overflow we prefer questions which are **focused** on a **single problem**. So, what exact problem you want to resolve? If you want to know how to share a memory between the kernel and user space, then references you got from your google request are actually the ones you are looking for. Or do you want to ask about "kernel to alert the userspace program"? In that case use appropriate google request. Like "linux kernel to alert the userspace program". – Tsyvarev Mar 27 '21 at 12:09

0 Answers0