C++ in kernel (was Re: exception in a device driver)

Thomas Pornin (pornin@bolet.ens.fr)
Tue, 12 Jan 1999 10:13:39 +0100


In article <199901101152.MAA07245@quatramaran.ens.fr> you write:
> template expansions can be incredibly powerful

Actually kernel programming is a bit different. Code efficiency is most
often I/O bound, and the important points are cache and TLB misses,
not complete loop unrolling or other things like that. Note that the
default optimization flag is -O2, not -O6. The C++ black magic may
induce (silently and depending heavily on the compiler) extra memory
accesses that are difficult to track down. This may be good for the
average cpu-eating application, but I think that the kernel requires at
least a specially tuned compiler (using C is then just tuning by hand).

I strongly suggest NOT using operator overloading anyway: it is very
difficult to do it consistently, and often prevents individuals from
getting a knowledge of the overall code structure. Linux has much
progressed because some people could understand the whole thing and
follow the Right Way.

An exception handling scheme for designing device drivers might be
a good idea, though, but it requires a major redesign, not merely
compiling with g++; and C++ is not the only solution. A project for the
3.1.x series I guess.

--Thomas Pornin

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/