[plug] Object Oriented Kernels?
The Thought Assassin
assassin at live.wasp.net.au
Wed Oct 4 13:04:39 WST 2000
On Wed, 4 Oct 2000, Oliver White wrote:
> The Thought Assassin wrote:
> > The Linux kernel is an example of OO code written in C.
> That's a curious statement. What examples can you give of object oriented
> code in the kernel? Examples of inheritance and encapsulation would be
> welcome.
As an example of encapsulation, look at the VFS stuff. Each filesystem
driver is effectively a class which implements (registering an array of
functions) a particular interface with all of the usual filesystem calls.
Each filesystem you mount is an object of that clas with its own data that
the VFS layer can only access via the standard interface.
This kind of model is typical of the Linux kernel, and of many large
well-written C programs. If inheritance is present in this model, then it
will be where some unimplemented functions of the interface default to the
version of the function present in the "parent class". While I don't think
this happens in the VFS, I have definitely seen this kind of code in other
parts of the kernel. C is flexible enough to emulate all of the OO
features built into C++, and good programmers/analysts will use the
appropriate elements of all the methodologies in their toolbox, regardless
of the language they are using.
-greg
More information about the plug
mailing list