User: Password:
|
|
Subscribe / Log in / New account

Linux kernel design patterns - part 2

Linux kernel design patterns - part 2

Posted Jun 16, 2009 0:03 UTC (Tue) by neilbrown (subscriber, #359)
In reply to: Linux kernel design patterns - part 2 by nix
Parent article: Linux kernel design patterns - part 2

I have a few reflections on this.

Firstly: it may well be that C is "expressively impoverished". Nevertheless, C is the language that Linux is written in, and that is not likely to change. So if we find ways to make best use of those constructs which C gives us, and document them as Patterns, we can work around some of the worse short comings while still keeping the result reasonably maintainable.

Secondly: if you look at cfq_rb_root in cfq-iosched.c, you will find an rbtree with an 'optimisation' that the left-most node is cached, as in that application it is often wanted. Implementing that requires making changes inside the 'add' routine. Keeping the implementation 'open' makes it easier to build that sort of enhancement.

Thirdly: it may well be that there is a "better" pattern available using macros or inlines or whatever. In writing the article I was not inventing patterns, but simply documenting them. If doing so helps people to see the weaknesses in the patterns and thus to improve the code by applying a better pattern, then we will have achieved something very worthwhile.

Thanks.


(Log in to post comments)

Linux kernel design patterns - part 2

Posted Jun 22, 2009 22:23 UTC (Mon) by nix (subscriber, #2304) [Link]

Oh, I agree with all of that. I wasn't saying that this was a *bad* thing:
obviously C is a pretty damn good language to write kernels in! (I wasn't
writing a kernel at the time.)


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds