Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

communicating a kernel module and an application.

hi,
  I have written a an application(user mode) and a  kernel module. i want to establish a communication between them. What is the procedure to call and run the functions of kernal module from external applications or vice versa. I also want to pass a block of data from that module to my application.
 I was thinking of createing a kernelthread and communicate using message passing. But i dont know how to do it?
 
Thanks.

 
0
manish_regmi
Asked:
manish_regmi
2 Solutions
 
PerlKingCommented:
I am not sure of this, but I think you have to use a "character device" to communicate to the kernel.

I remember that in one of the projects I worked on our application had to communicate to the kernel. So, the approach we took was to write a device driver for a character device and place the data in this device. The device driver takes care of putting it to the kernel. (Pardon me for talking vaguely here, but I was just a sophomore when I was involved in this project and I hardly remember anything now)

If you could find a copy of O'Reilly Linux Device Drivers, 2nd Ed., it is an excellent place to start. "Chap 3: Char devices" is what you should be looking for.

http://www.oreilly.com/catalog/linuxdrive2/toc.html
0
 
Anthony2000Commented:
Here is a link to the book online: http://www.xml.com/ldd/chapter/book/

The example programs can be found: http://examples.oreilly.com/linuxdrive2/

There are several ways to facilitate communications between application (user mode) and driver modules. Rubini's book covers some (or all) of them.

I have used portions of Rubini's memory driver and I have used the ioctl function to pass data in and out of the driver.  I  have also used the open, read, write driver interface functions.

One of the easiest ways to start is to compile and try the examples in the book. If you get stuck, just post what you are running into here and we can help.

> What is the procedure to call and run the functions of kernal module from external applications
Basically you can use the ioctl interface or the open, read and write.

Why do you need a kernel thread? I was just wondering.

Anthony

0
 
manish_regmiAuthor Commented:
hi,
 perlking and anthony2000,

I already have those books. thanks anyway.
 I got your point. You mean i need to create a character device and communicate through it.

-->Why do you need a kernel thread? I was just wondering.

Because i was not sure what to do.

Thanks for all your help.




 
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now