Re: C++ in the kernel



On Mon, Oct 29, 2007 at 08:22:22PM +0000, Poul-Henning Kamp wrote:
Not really. I've personally bugged Bjarne about making C++ usable
for systems programming ever since 1987 or so, but to no avail.

I can also see some benefits in parts of C++ - we already simulate
bits of classes, inheritance and templates in the kernel and having a
language where this was an integral part of the language should
improve code readibility and reduce scope for errors. I also agree
that C++ brings with it far too much baggage and allowing a useful
subset into the kernel would lead to the rest of the camel following
over time.

One thing that particularly bothers me, is that compilers offer
no assistance in debugging, because normal programming runs in the
UNIX virtual machine, attaching a debugger is the preferred way.

Virtualisation offers one way of making kernel debugging less painful
but I agree that debugging a mis-behaving kernel is much harder than
debugging a userland application.

Imagine for instance an option to zap the heap with 0xdeadcode on
function return or an option to check all function pointers for
non-null-ness before jumping through them.

Both these should be fairly simple patches to gcc. The former would
be useful in application programming as well as kernel programming and
could therefore make it back into the vendor gcc.

I don't really see the benefit of the latter - calling a NULL function
pointer will immediately trap and trigger a panic. For much of the
kernel, it's not clear what else to do. Possibly there are some cases
where the kernel could take recovery action and continue but that
requires much finer control than a compiler switch - it would seem
easier (and more efficient) to add code into the trap handler to
recover from expected traps (much as copyin() and copyout() do now)
than add a conditional test to every call instruction.

Note that neither of these imply a change to the language.

Maybe, in another thread, you might like to discuss your ideas for what
additional features our development toolkit should have to assist with
kernel development.

--
Peter

Attachment: pgp6hu1p3wv5S.pgp
Description: PGP signature



Relevant Pages

  • Seek Contract Programming Work - 17 Years Experience
    ... where I did nothing but debugging and optimization. ... electric keyboard), so I enjoy writing MIDI, audio and music applications. ... file format to the C++ API) for a financial firm in the Bahamas, ... to handle any sort of programming task. ...
    (comp.programming)
  • Seek Contract Programming Work - 17 Years Experience
    ... where I did nothing but debugging and optimization. ... electric keyboard), so I enjoy writing MIDI, audio and music applications. ... file format to the C++ API) for a financial firm in the Bahamas, ... to handle any sort of programming task. ...
    (comp.lang.java.programmer)
  • Re: [PATCH 0 of 4] Generic AIO by scheduling stacks
    ... thought we couldn't do native kernel threads for "normal" threading ... disciplines in question: i hacked on scheduling, 1:1 threading, on Tux, ... the programmer from the risks and complexities of thread programming, ... Having a 1:1 relationship between user-space and kernel-space context is ...
    (Linux-Kernel)
  • Re: [RFC/PATCH] Documentation of kernel messages
    ... On Fri, 15 Jun 2007 11:51:51 PDT, Randy Dunlap wrote: ... And "for debugging" doesn't cut it IMO. ... people doing support can annotate the messages with real life experience on ... Providing a means for getting localized kernel ...
    (Linux-Kernel)
  • Re: Development engineering
    ... Yeah, debugging skill #1 is diagnosis -- fixes are easier, more often ... The skills of, say: finding bugs; ... the deucedest ones in my experience), distributed programming (...runs ... that debugging -- if I took a week to learn it, ...
    (comp.lang.python)