I’m developing an application (user space) which send notifications of value changes via network.
I want to develop a kernel module (A) in order to notify my application (user space) in case of value change in a parameter in other kernel module (B).
- How to send signal from the kernel module (A) to my user space application ?
- How to send data from the kernel module (A) to my user space application ?
- How to call functions and variables from the kernel module (A) in the kernel module (B)?
Accessing module B from module A
Define a header in module B like a normal C header that includes the variables/functions that A wants to use, and of course
#includeit in A.In one of the source files of B, write:
for each of the variables/functions.
In the Makefile of module A, make sure you add the path to Module.symvers of B in the
KBUILD_EXTRA_SYMBOLSto get rid of dependency warnings and be able to load the module if your kernel has been configured withCONFIG_MODVERSIONSSignalling a user-land process
Honestly, this one I don’t know much. I personally code with a real-time extension of Linux (RTAI) for my work and I have facilities that I don’t think exist in plain Linux. These facilities are shared memory (between kernel and user), and shared semaphores (again between kernel and user) and the like. If you could find such a thing in Linux, then you can use it.
If those are not available (which I believe they are not), you can always simply write a /sys or /proc file that outputs a simple 0/1 showing whether the user-space application needs to be signalled or not. Then the user-space application can poll this file.