On Mon, 2002-06-10 at 17:56, Muli Ben-Yehuda wrote:
> [Email Advisor Warning: language flamewar brewing, possibility
> 60%. Dump message? NO. Are you sure? YES. Really? YES. Really Re^C^C]
>
> On Mon, Jun 10, 2002 at 05:22:17PM +0300, Gilad Ben-Yossef wrote:
> > On Mon, 2002-06-10 at 13:28, Muli Ben-Yehuda wrote:
> >
> > > As for implying that we might write kernel modules in C++, sir, such a
> > > comment would cause me (as a Qlusters kernel hacker) to demand
> > > satisfaction at dawn, sir. I'll settle for a beer after the revolution
> > > OS event, though ;)
> > >
> >
> > Sorry to burst your bubble, but one of the coolest pieces of code I had
> > the fortune to work with the in the past is the Click Modular Router and
> > it is implmented as C++ classes and objects and can run in kernel space
> > (as well as out of it).
>
> Sorry, Gilad, but I have a hard time believing you can use c++ code in
> the kernel and still have anything that remotely resembles c++ *as it
> should be written*, rather than souped up c. Whatever happened to "the
> right tool for the job"?
Oh, I never claimed it is a good idea in general. CMR is an academic
project and for that their use of it is VERY suitable IMHO.
>
> I'll go check the source out now. It's too hot to actually get any
> work done today ;)
>
> Ok, a quick look shows what I expected it to show, c++ code that looks
> like c in first and second glance. No templates, in inheritance, no
> overloading, none of the things that make c++ c++. In the kernel, I
> don't care if the struct is called 'class', and if you pass an object
> by reference instead of by pointer, and if you have a string class,
> instead of a char*.
Look again. No templates is true AFAIK. No inhertience isn't true and
they even have a run time tool to relace the virtual table mechanism at
load time of click modules to save CPU cycles ofderefernce (because they
know when you load configuration the actual types so they can do late
linking similar to what goes on with a kernel module when it). I'm
pretty sure overloading is used too (or it least can be used - maybe the
code you looked doesn't use this specific feature but it is supported).
In short, I do belive this is a real and honest use of C++ in kernel.
True, it is a very specific use. True, you *can* do it C (obviously,
since you have C++ compilers written in C etc etc ad Turingum). Would I
choose such an approach if I would to implment such a system myself? no
and I did and I haven't. But it is there and it's working, and working
*very* well let me tell you, just under 10% of the Linux kernel itself.
In fact, for certain configurations it beats the pents of the vanilla
Linus tree in throuput, although for reasons that has nothing to do with
C++ and is done a hack that can be applied to the Linus vanilla tree too
and is supposed to be resolved in a much more general fashion on 2.5
(I'm speaking of network interrupt mitigation to prevent itnerrupt live
lock to those who care).
> Don't get me wrong, I LIKE c++ and I like coding in it - in
> userspace. I just don't see what adding c++ to the kernel buys you.
One of the cool features of this system is that you develop Click
modules and then can compile them to run in user space or kernel space
with out code change. This is a god sent for debugging and quick
development cycles.
--
Gilad Ben-Yossef <[EMAIL PROTECTED]>
Code mangler, senior coffee drinker and VP SIGSEGV
Qlusters ltd.
"A billion flies _can_ be wrong - I'd rather eat lamb chops than shit."
-- Linus Torvalds on lkml
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]