Re: exception in a device driver

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Wed, 6 Jan 1999 12:43:01 +0000


On Mon, Jan 04, 1999 at 04:22:05AM -0500, Anthony Barbachan wrote:
> There's also usually a huge amount of overhead associated with C++
> exceptions, probably not a good idea for a Linux driver.

The time overhead is supposed to be very small in the case that _no_
exception is raised. Smaller than straightforward error checks in many
cases. There is a considerable code size penalty.

In practice, errors in drivers and kernel functions are not at all rare
-- they are quite normal for file operations, for example. (e.g. check
if file exists -> ENOENT).

> Furthermore the simpliar method of checking the returned value(s)f
> functions is also easier to understand, read, and debug.

The way it works in the kernel, I completely agree.
And it has the right performance characteristics, too.

The automatic constructor/destructor thing is supposed to be neat, but
for cleanups like the ones you see in the kernel, you'd end up with more
sugar coating than whatever goes in the middle.

-- Jamie

-
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/