Android A to Z

What is a kernel?  If you spend any time reading Android forums, blogs, how-to posts or online discussion you'll soon hear people talking about the kernel.  A kernel isn't something unique to Android -- iOS and MacOS have one, Windows has one, BlackBerry's QNX has one, in fact all high level operating systems have one.  The one we're interested in is Linux, as it's the one Android uses. Let's try to break down what it is and what it does.

Android devices use the Linux kernel, but it's not the exact same kernel other Linux-based operating systems use.  There's a lot of Android specific code built in, and Google's Android kernel maintainers have their work cut out for them.  OEMs have to contribute as well, because they need to develop hardware drivers for the parts they're using for the kernel version they're using.  This is why it takes a while for independent Android developers and hackers to port new versions to older devices and get everything working.  Drivers written to work with the Gingerbread kernel on a phone won't necessarily work with the Ice Cream Sandwich kernel.  And that's important, because one of the kernel's main functions is to control the hardware.  It's a whole lot of source code, with more options while building it than you can imagine, but in the end it's just the intermediary between the hardware and the software.

When software needs the hardware to do anything, it sends a request to the kernel.  And when we say anything, we mean anything.  From the brightness of the screen, to the volume level, to initiating a call through the radio, even what's drawn on the display is ultimately controlled by the kernel.  For example -- when you tap the search button on your phone, you tell the software to open the search application.  What happens is that you touched a certain point on the digitizer, which tells the software that you've touched the screen at those coordinates.  The software knows that when that particular spot is touched, the search dialog is supposed to open.  The kernel is what tells the digitizer to look (or listen, events are "listened" for) for touches, helps figure out where you touched, and tells the system you touched it.  In turn, when the system receives a touch event at a specific point from the kernel (through the driver) it knows what to draw on your screen.  Both the hardware and the software communicate both ways with the kernel, and that's how your phone knows when to do something.  Input from one side is sent as output to the other, whether it's you playing Angry Birds, or connecting to your car's Bluetooth.  

It sounds complicated, and it is.  But it's also pretty standard computer logic -- there's an action of some sort generated for every event.  Without the kernel to accept and send information, developers would have to write code for every single event for every single piece of hardware in your device.  With the kernel, all they have to do is communicate with it through the Android system API's, and hardware developers only have to make the device hardware communicate with the kernel.  The good thing is that you don't need to know exactly how or why the kernel does what it does, just understanding that it's the go-between from software to hardware gives you a pretty good grasp of what's happening under the glass.  Sort of gives a whole new outlook towards those fellows who stay up all night to work on kernels for your phone, doesn't it?

Previously on Android A to Z: What is the JIT?; Find more in the Android Dictionary

 

More from the Android Dictionary

Pages

 
There are 16 comments

ScottJ says:

I don't intend to be rude, but AC should hire someone who knows how to write a how-to article for this series. Jerry's articles are better than Phil's, but they still are jumbled mess.

Some of the smartest people I know are abysmal at explaining things. If you intend on publishing these types of articles going forward, you should find someone who both understands the tech and is able to write a basic how-to article that has effective structure and hits on all the key points of the subject matter.

icebike says:

I thought it was as well written and easy to understand.

Some things were glossed over, but you expect that in an introductory article.
Perhaps if you re-read it using your grandmother's point of view you will find it less jumbled and more informative. You could also perhaps write one yourself and show us how it is supposed to be done.

themuffinman says:

Nothing was wrong with the article. Its meant to give a general idea as to what a kernel is and thats it. If he went into specific details the article will end up being way to long of a read for most not to mention there will probably be a lot of technical terms that most will have a problem comprehending. Most people care about what something is compared to how it works and thats what this article is about.

Thanks for the input, but these aren't white papers, nor are they attempting to be.

And, yeah. That was kinda rude.

aubreyvt says:

@ScottJ. I don't intend to be rude but... go pound sand. I am not sure what you are expecting for detail but out of these A-Z definitions this one was not at all a jumbled mess, nor any other one for that matter. I think they did a fine job at explaining the Kernel. Not obnoxiously long and not to vague. Thanks Jerry and keep it up.

ryguymoeller says:

I understood this completely while listing to ESPN and trust me my reading comprehension skills are not good

Hand_O_Death says:

Soooo, Magic. Got it thanks.

And it got the point to me so well put Jerry, thanks.

dan in la says:

I'd like to learn about this in more depth. Can anyone recommend where I should look next? I'm looking for something that would get into some more of the technical details but isn't written at the level of someone who's already a serious developer.

Try the book Linux Kernel in a Nutshell by Greg Kroah-Hartman.  You can order it from O'Reilly but a local library may have it and save you some cash.

 

 

dan in la says:

Thanks very much. I'll definitely take a look.

plunder says:

Dear Jerry. I have heard two things about iOS and Android that seem to be contradictory, they confuse me.

They say iOS prioritises the Visual User Interface over system related events - thus keeping taps and sweeps that reflect such movement more direct and fluid.

The same people tell me that Android OS cant change that priority for some reason. I do not understand that. With all the processing power coming into Android devices (Dual-Core, Quad-Core etc) is it still true? If so why?

iOS runs all UI activities in one thread that has a higher priority than anything else.  

Android runs UI activities in their own thread with the rest of the application's processes.

In iOS, everything behind the scenes stops so the UI can be drawn, in Android the back-end still runs at the same priority when applications (and their UI) get focus.  It's a trade off -- iOS scrolls smoothly and does nothing for a few seconds but scroll, Android will stutter under load (in scrolling or other UI functions) but continues to work in the background.  In the end, neither gets "done" faster than the other because you have to wait for it all to load.

Because we hack, we can cheat Android by reserving more free RAM for apps to grab while opening, but that still doesn't re-nice the UI threads -- only gives them more RAM.  CPU time is pretty much pre-determined.  With Honeycomb and ICS, animations have been slowed down.  They look and feel slower, but are much smoother.  

Follow +Dianne Hackborn on G+.  She's the Nerdette Goddess of all this stuff :)

ronnienyc says:

I agree that this article is a bit of a mess. How far along do you get before the definition of a kernel shows up?
Answer: the third paragraph.

If you are going to start the article with "What is a kernel?" then you should not wait until sentence #12 in paragraph #3 to state what a kernel is.

The whole thing is jumbled, IMO.

I am a techie so I get it, but someone who is not would just be baffled reading this article as it stands.

(No offence or disrespect to the author.)

DC Damien says:

Thanks Jerry. Very helpful.

ryguymoeller says:

I don't know why everyone is complaining about this. I liked the series because it is more information than I would ever get. Keep up these articles please.

Lummix says:

You should add API. For those who don't know, an API is an Application Programming Interface. I didn't see that one in the dictionary but it is a very common acronym.

Pages