Rixstep
 About | ACP | Buy | Industry Watch | Learning Curve | News | Products | Search | Substack
Home » Industry Watch

Lion: Kernel Panics

They're not supposed to happen; if they do happen, something is very wrong.


Get It

Try It

CUPERTINO (Rixstep) — Apple's computer OS X 10.7 Lion has been out since 20 July. Although most Twitter traffic is about scrolling, an uncomfortable percentage concerns the feared kernel panic.

This is something that's never afflicted any OS X before to any significant degree. Something is not right with OS X 10.7 Lion.

Kernel Panic?

A kernel panic is an action taken by an operating system upon detecting an internal fatal error from which it cannot safely recover.
 - Wikipedia


Computer processors run in different modes. The most important modes are 'ordinary' ('user land', 'nonprivileged') mode and 'privileged' or 'kernel' mode. Ordinary applications run in nonprivileged mode. They're bound inside a 'virtual' system with no actual access to the computer hardware. Such a system is used because computer hardware today is a shared resource being used by different applications (and users) all at once, and because direct access to the hardware can cause issues (such as crashes).

The 'underbody' of a computer system has to be much more stable than the upper reaches. Vendors come in all the time with code that's not properly tested; this code cannot be allowed to jeopardise the stability of the system. Programmers test new code all the time and no code is perfect, at least during the development cycle. That code can't be allowed to jeopardise system stability either.

The 'underbody' - the kernel - is code everybody and everything uses. It's incredible sensitive. It has to maintain the illusion of multitasking. It has to know how to talk to drivers. It has to be written meticulously. (Look at kernel source code sometime and you'll see - there's a studiousness to kernel writers you won't find anywhere else.)

One single flaw in a kernel and the whole house of cards comes tumbling down.

Linux is known to get kernel panics from time to time. Linus Torvalds had the opportunity early on to make an architecture change which might have ameliorated this but decided against it. OpenBSD and FreeBSD get their panics as well. Any bad driver code can cause it - it doesn't have to be the kernel itself.

But Apple's OS X? Almost never. There have been zero/zip kernel panics for most OS X users in perhaps ten years of use on multiple machines. Why?

Microkernel Architecture

A microkernel is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system. These mechanisms include low level address space management, thread management, and inter-process communication.
 - Wikipedia




Apple's OS X is based on NeXTSTEP which in turn avails itself of FreeBSD with a microkernel ('MACH'). A microkernel outsources as many tasks as possible back to 'user land'.

Apple's kernel is called 'XNU' and is inherited from NeXTSTEP. XNU is today a hybrid, of both the monolithic model used on Linux and the pure microkernel model. The MACH microkernel can run most system tasks in separated processes, provides kernel execution threads, preemptive multitasking, IPC, protected memory, VM management - all the good stuff a OS needs.

The essence of a microkernel is to not try anything that can be done in 'user land'. Kernels run in privileged mode - they can access everything in the computer. Everything.

They can access real memory - and thereby overwrite other running programs. They can access anything on the hard drive - and thereby circumvent file permissions. They can write anywhere on the screen - and make your desktop a mush.

Although some tasks need to be carried out in kernel mode, many do not - and so microkernel architects will delegate the tasks to code not running in kernel mode. If something goes south, then it's only a user land execution thread that's affected - not the entire operating system.

Which is why Apple's OS X traditionally didn't experience kernel panics whilst other Unix distributions did. There's a small performance write-off with microkernel architecture, but most OS X users are undoubtedly happy to pay that small price for system stability.

David Cutler's Kernel

Avie Tevanian came to NeXT at about the same time his Carnegie-Mellon colleague Rick Rashid went to Microsoft, at about the same time DEC's David Cutler was invited to Building 8 on the Microsoft campus. Both Rashid and Cutler were strong advocates of the microkernel, and Cutler's 'NT' started with a microkernel architecture as well.

Cutler changed Windows NT architecture dramatically with the release of version 4.0 in 1996 - he moved the Win32 subsystem (perfectly capable of running in user land) into the kernel (as Win32k.sys) to speed things up.

The unfortunate result was the BSOD - 'blue screen of death' - seen before that mostly on old 16-bit Windows systems. Bad drivers were most often the cause - code not written by Dave or his colleague Lou Perazzoli.

Of course it could be the 10.7 drivers that are screwing up - and not the drivers Apple engineers themselves write, but the drivers third party vendors supply. But most OS X users have never heard of kernel panics, much less experienced them, not in the ten years OS X has been available. Now with Scott's elite crews on other projects, and despite the heavy names in Cupertino today, they're happening all over the place.

Something points to there being something very wrong in Lion. Bottom line? Don't rush to upgrade.

Look. A kernel panic. The last I had was on Leopard.
 - @chengfu
AAAAAHHHHHH! Kernel panic in the morning! If this continues, the #Lion goes down for good. Unstable junk!
 - @cproell
That does it, but really! Kernel panic again! We should pop Steve Jobs' junk about his ears!
 - @cproell
Thanks #Lion, I haven't gotten a kernel panic in years.
 - @danheberden
And yet ANOTHER #Mac #OSX #Lion black screen kernel panic on MacBook Pro i7. Going back to Snow Leopard completely. #YouBumMeOutApple
 - @jimmitchell
first kernel panic in years :| #lion
 - @kerin
that makes me wonder: is the kernel panic screen also redesigned? :)
 - @roelvangils
hmm, kernel panic after starting the #android emulator...not good #lion :(((
 - @seboslaw
Hurray! 2nd kernel panic. #Lion
 - @stijnworks
after having a good day yesterday with just one kernel panic - today I already got five - waiting for 10.7.1 #mbp #lion
 - @tOMPSON

See Also
Industry Watch: 10.7 Roars
Industry Watch: Lion: 'Ten Days After'

About | ACP | Buy | Industry Watch | Learning Curve | News | Products | Search | Substack
Copyright © Rixstep. All rights reserved.