CTO of Eklektix, Inc.
Executive Editor, Linux Weekly News
Author, O'Reilly and Associates
LinuxCare's Kernel Journal
Jonathan Corbet is the co-author of O'Reilly and Associates upcoming 2nd Edition of Linux Device Drivers. He is also the CTO of Eklektix, Inc., and the executive editor of the online magazine, Linux Weekly News. O'Reilly Network's Stephen Figgins spoke with him about the upcoming kernel and how to get a handle on writing drivers for it.
Listen to this interview:
Stephen Figgins: Jon, for a couple of months on the O'Reilly web site Linux Device Drivers was the most popular web page viewed and the book sales have gone very well. I thought that was surprising. Do you have any insights on why that might be such a popular topic for us?
Jon Corbet: One could imagine a few reasons I suppose. There was a rumor that a certain large hardware manufacturing company had told all of its engineers to buy that book back last spring, I think. And, I think that may have created a surge.
But, in more general terms, the interest in the Linux operating system in general, of course, is as high as it's ever been and is only growing. More interest in the system translates to more interest in making particular hardware work with the system as more manufacturers want their products supported, or as more users wish to be able to use their products. And that will certainly account for part of the increase. I think also that a lot of people simply pick up the book as a way of learning about how the Linux kernel works--how the system works underneath the hood. Because there still aren't that many books out there that one can get to learn about that area of the system.
Figgins: Device drivers are considered a part of the kernel itself?
Corbet: Device drivers are a part of the kernel.
Figgins: I always thought of them as programs used by the kernel to speak with hardware, such as a parallel port, serial port, or video card, well, just about anything that you would plug into your computer?
Corbet: Well, the kernel uses a device driver, right, as part of the kernel. Any user really, as a general rule, doesn't want to have to worry about device drivers. They're dealing with things at a higher level.
Figgins: In the new edition of the Linux Device Drivers book will both the 2.2 and 2.4 versions of the Linux kernel be covered?
Corbet: Yes, both those versions will be covered, especially if 2.4 actually settles down any time real soon. There are still some pretty important changes that are happening there.
Figgins: We'd expected the kernel to be out by now (January 2000).
Corbet: Yeah, it's not going to be out for some time. And, in fact, some of the core programming interface issues are still in flux. So, my guess is that springtime at best, and perhaps late spring at that.
Figgins: I understand you've wrapped up the first couple of chapters on the new edition and plan to dive into something juicy next. What is it that you're planning on moving onto?
Corbet: Well, I'm pretty much progressing sequentially through the book at the moment. I am right now putting the last touches on the third chapter, which is on character device drivers, which is where the book really first begins to delve deeply into how you do things and a lot has changed there. So, that will be passed back to O'Reilly hopefully this week sometime. And, then I'll just keep on going from there pretty much from one end to the other.
Figgins: Many of the devices supported on the new 2.4 kernel we haven't seen before, like the USB device driver (the Universal Serial Bus) and also infrared support. Are there any that are particularly exciting to you at this point in time?
Corbet: Well, a great deal of hardware support is, of course, being added with the 2.4 kernel. I think the USB stuff is actually the most interesting personally and I intend to add a chapter to the book that describes how you write drivers for USB devices. The Universal Serial Bus has brought around a whole new set of devices to the Linux world that need to be supported. And, USB devices, of course, work in a way that's very easy for the users since they can simply plug them into a hub and not have to worry about opening up their box or anything like that. The USB devices also add a number of interesting challenges. The devices come and go as the system is running, which kind of changes the Linux view of hardware in general. The kernel has handled that to an extent so far with PCMCIA, but USB really ups the ante in that regard. Printers or disk drives can simply appear on the system at absolutely any time and it has to be dealt with in a way that makes the user able to access these devices once they're plugged in.
Figgins: I noticed that Microsoft has support in Windows 98, but has not yet rolled it into NT with some form of upgrade, although they plan on doing that in 2000. Is this a particularly thorny device to implement?
Corbet: It's complex, and USB, of course, is not a single device, but a new way of accessing a whole range of devices. So, you don't just have one device driver, you have conceivably hundreds of them. And, again, it does change the way in which you deal with hardware. So, there are challenges to it. There's nothing that can't be overcome.
Figgins: It's marked as an experimental driver in the 2.4 kernel. Exactly how experimental will it be?
Corbet: I would expect the experimental designation to disappear before 2.4 is actually released. It was certainly experimental in 2.2. It got thrown in really right toward the end of the 2.1 development series there. The development on USB currently is very high. There's a lot going on there and a lot of work going into stabilizing it and making it work properly before the 2.4 kernel comes out. USB should be fully supported in 2.4 and not an experimental driver, as such.
Figgins: Linux Device Drivers, the book, came out covering the 2.0 kernel and some of the 2.1 developmental kernel, but it was just before 2.2 release. When the new kernel came out, there were quite a few people who had problems getting the examples to work. Looking forward to 2.4, or for those people who are currently working with 2.2, are there particular issues that a programmer should know about when updating a device driver to give them a leg up while waiting for this new edition of the book?
Corbet: Oh, there's a whole long list of those. Um, with regard to 2.2, remember that Alessandro had access only to 2.1.44 as the latest kernel version when he added his appendices to the book on that.
Figgins: The odd number, .1 in 2.1, designates a developmental kernel, what would eventually be 2.2?
Corbet: Yeah, but the 2.1 series went beyond 2.1.44 through to 2.1.100--somethingI forget exactly what. There was a great deal that happened afterward, so it's not surprising there were changes that weren't reflected in that book, some fairly significant ones. There's not a whole lot that's easy to point out in an interview. There's just a whole bunch of API, programming interface changes, that happened that have to be accounted for. Actually, the best place to look for those is in a series of articles written by Alan Cox that appear in Linux Magazine. Those, I believe, are online now on the Linux Magazine site.
2.4, of course, is adding a whole new set of changes. The one thing I guess I would point out, other than, again, a long series of API changes, is that the modern Linux device driver writer has to be aware of multiprocessor systems, even if they don't have one on their disk. If you don't write your driver for such systems, then a lot of people will not be able to use it. And that means dealing with a whole bunch of multiple access, critical section and contention issues that simply didn't come up really even in the 2.0 kernel.
Figgins: The book will be greatly expanded then?
Corbet: The plan is to expand the book by about 50 percent of its original size, although that's an approximation at best. But, there will be a lot of new material in the book, including coverage of multiprocessor systems, USB and a lot of other things.
Yeah. I'm having an awful lot of fun working on the book. It's the nature of a book like this that no matter how much you know you still learn a lot going through the process of actually trying to lay everything out and I am certainly learning quite a bit. I'm having a lot of fun working with Alessandro [Rubini, the author of the first edition of the book] on updating this and I hope I can produce a product that's up to the quality of its predecessor.
Copyright © 2009 O'Reilly Media, Inc.