New to Linux programming in general.
I am trying to communicate with a kernel module via shared memory, but cannot call the functions used in user apps such as shmget(); I have installed kernel-headers and kernel-devel, and included , to the kernel module source, but the headers do not contain any functions.
Is there a standard way of using shared memory in the kernel?
Also, any tips on how to use sockets in the same situation will be of great help.
Using Distro: CentOS 5.2 kernel: 2.6.18-92.1.22.e15
Thanks in advance.
//Added// To clarify, I am trying to make a demo that has common features of a typical embedded linux project. The final goal being porting it to LynxOS to see what kind of troubles may occur when doing so on larger projects.
Currently the main features of the demo is multi-process, pipes, message ques, shared-memory, sockets, multi-threads.
It has an user app and a loadable kernel module communicating with each other. pipes and messages between two processes within the user app, and shared-memory and sockets between the user app and kernel module.
If I am doing something plain off-course, please tell me.
Your purpose does not look very clear to me. Shared memory is not a way to communicate between user space and kernel space. If you want to have access to some kernel allocated memory, one way to go is to implement the mmap system call.
If you really need to write some kernel code, a recommended reading is : linux device driver third edition, and chapter 15 is the one you are looking for.
Once you have shared memory, you probably will need a way to do some synchronisation, ie working on one part within the kernel, while using another part in user space. An example of userspace / kernel sharing of memory is the V4L2 API. An more friendly explanation can be found in the LWN series about it.
However, if you were more specific in what you want to do, you would receive more specific help on the way to do it, if you really need a kernel module, which kernel code you could have a look at and so on.
For the socket thing, I don't know enough, but you should google for linux + kernel + netlink. It is used to communicate with the kernel from user space via "standard" socket call, but I have really no idea on how to use it in a module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With