[bitlug] Re: Writing kernel modules in C++

  • From: Turuvanur Pavan-A20404 <pavan.tc@xxxxxxxxxxxx>
  • To: bitlug@xxxxxxxxxxxxx
  • Date: Mon, 12 Jul 2004 12:14:08 +0530

>  went here, and am almost convinced that this is a bad idea...
> would be interested in knowing why you ppl have to do this...

Well, the answer is kinda non-technical.
The sole reason why this is required is because there are huge modules
that have already been written in c++ and ppl want to reuse this code.
They dont want it to be re-written in c. A few changes to make it a
kernel module are acceptable, is what they say. Earlier, a lot of
this functionality was in the user space, and now, they have to be
put into the kernel and this is where the necessity arises.

The solution, however, is not very simple. As we can see, the kernel
developers give a damn to c++ support in the kernel. Hence, you'll 
see that there are varibles named "new" and "private" and stuff like
that in kernel code that are keywords in c++. 
The compiler straight away cribs, once you want to make a c++ 
kernel module, since there are a lot of #includes of files which 
are unacceptable for a c++ compiler.
Now, the unavoidable thing is to patch the kernel, get rid of things
unacceptable to c++, and recompile it. The link to the click-modular
router that i had sent in the previous mail talks about this. This
is a humongous task though. The best idea is to get a patch which
will do it for us and be happy about it. The newer versions of
RTAI also provide c++ support and this is what i'm probing at, at the
moment. Take a look at this link to get a hang of RTAI.
http://www.aero.polimi.it/~rtai/documentation/index.html

>    What is a kernel module?

A kernel module can be anything stretching from a device driver 
to the memory management subsystem and further. Anything, theoretically
can be a kernel module. Take a look at the "Linux Kernel Module
Programming" link among the list of other very interesting links here.
http://www.linuxhq.com/lkprogram.html

>    What is insmod-ing?
The answer to this question is there as well. very crisp and tidy.

TC
------------------------------------------------------------------------

Other related posts: