Re: Linux kernel modules development in C++

From: Timur Tabi (ttabi@interactivesi.com)
Date: Wed Sep 27 2000 - 16:36:16 EST


** Reply to message from Wayne.Brown@altec.com on Wed, 27 Sep 2000 16:15:31
-0500

> But where's the advantage in using C++? Plain old C has served admirably in
> UNIX and Linux development since the very beginning. What more can C++ offer
> for driver development that outweighs the reduced accessibility of the code to
> those of us who are more proficient in C?

Well, people said the same thing to me when I started writing OS/2 drivers in
C++. Nowadays, it's very common for non-*nix operating systems, especially
Windows.

The real advantage comes when you're writing a driver where the design is
inherently object-oriented. I can't give an example in Linux, because I've
only been writing Linux drivers for 6 months, but in OS/2, there are tons of
places where a little OO lovin' goes a long way. My initial use was in
multimedia drivers. In OS/2, the adio drivers need to keep track of multiple
"streams" of audio data. OS/2's advanced multimedia subsystem lets multiple
applications open audio streams simultaneously, and the driver has to keep
track of them. If it has the hardware, it can play the streams simultaneously.
 Otherwise, it has to manage stopping one stream to play the other.

I've oversimplified it, but that's the general idea.

This design is inherently object-oriented. The old C code for audio drivers
was horribly convoluted. When I rewrote it in C++, there was less code, it was
easier to maintain, and ther resulting binary was actually smaller and faster!
And that's all because the language fit the design better.

-- 
Timur Tabi - ttabi@interactivesi.com
Interactive Silicon - http://www.interactivesi.com

When replying to a mailing-list message, please don't cc: me, because then I'll just get two copies of the same message. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Sep 30 2000 - 21:00:20 EST