Linked by Thom Holwerda on Wed 21st Jan 2009 11:30 UTC
Hardware, Embedded Systems We've been able to drop the world of 32bit for a while now, with 64bit processors and support for them being prevalent in all popular, modern operating systems. However, where Mac OS X and Linux seem to make the move to 64bit rather effortlessly, Windows has more problems. Even though 32bit applications should run fine on 64bit Windows, some don't; and to make matters worse, drivers need to be 64bit, as there's no support for 32bit drivers in 64bit versions of Windows. Still, Gizmodo claims that with Windows 7, the time is right to take the plunge. But really, is it so? And why do Linux and Mac OS X seem to handle the transition so much easier?
Thread beginning with comment 344696
To read all comments associated with this story, please click here.
Detlef Niehof
Member since:
2006-05-02

FTA:

Mac OS X circumvents this issue by running the kernel in 32bit, allowing 32bit drivers to run without any problems (the kernel in Snow Leopard is supposed to be 64bit). The userland applications run in 64bit, however, so users still get many of all the benefits.


I'm somewhat confused by this statement. From the Wikipedia page about x86-64 http://en.wikipedia.org/wiki/X86-64 it seems to me that 64 bit features of x86-64 CPU's can only be used in Long mode, and in order to get into Long mode, there must be a 64-bit kernel. If a kernel "runs in 32bit" (as stated in the article), the CPU should run in Legacy mode, making the 64bit features unavailable.
Also, the meaning of the parenthesis "(the kernel in Snow Leopard is supposed to be 64bit)" is not clear to me. Does it mean that since the Snow Leopard release of MacOS X the kernel does not "run in 32 bit" anymore, thus making the aforementioned technique (that I find dubious anyway) of running 32 bit drivers impossible?
Clarification would be appreciated! :-)

Thom_Holwerda Member since:
2005-06-29

Well, I remembered the info from Ars Technica [1], and confirmed it in several other places [2] [3]. Sadly, Amit Singh's websites are offline at the moment, so more detailed explanations will have to wait.

[1] http://arstechnica.com/reviews/os/mac-os-x-10-5.ars/6
[2] http://en.wikipedia.org/wiki/64_bit#Software_availability
[3] http://en.wikipedia.org/wiki/X86-64#Mac_OS_X

Reply Parent Bookmark Score: 1

gousiosg Member since:
2006-03-02

On my Core 2 MacbookPro the kernel seems to run in 32bit mode.

MacBook:/ gousiosg$ file /mach_kernel
/mach_kernel: Mach-O universal binary with 2 architectures
/mach_kernel (for architecture i386): Mach-O executable i386
/mach_kernel (for architecture ppc): Mach-O executable ppc

Reply Parent Bookmark Score: 1

Detlef Niehof Member since:
2006-05-02

Thanks, you're indeed right. Especially your second link provides some insight. The more I'm thinking about it, I find the Wikipedia page about x86-64 somewhat contradictory:

Long Mode
(...) It is used by 64-bit operating systems. (...)


which makes it sound as if only 64 bit operating systems can use the 64 bit features of the CPU (and which, in retrospect, also raises the question what constitutes as a "64-bit operating system").
Later, in the Mac OS X section, they claim that Mac OS X v10.5 uses the 64 bit capabilities of the CPU and also that "The kernel is 32-bit."
Hm. I guess I should put my thoughts on the Wikipedia x86-64 Talk page...

Reply Parent Bookmark Score: 1

elanthis Member since:
2007-02-17

OS X uses a microkernel architecture, so it's entirely possible for parts of it to run in 64-bit and other parts to run in 32-bit mode.

Think of it in a similar way to using nspluginwrapper to run 32-bit Java/Flash in a 64-bit Firefox. The drivers run as separate 32-bit processes (with kernel privileges) that are managed by a 64-bit kernel scheduler.

(That is what I'm guessing is going on, anyway.)

Reply Parent Bookmark Score: 2

davdoc Member since:
2009-01-21

While I am not sure if Apple ever really revealed the details regarding how 32-bit and 64-bit codes coexist in OSX (prior to 10.5), based on the AMD64/Intel 64 architecture specification it is possible to mix 32-bit and 64-bit codes in kernel(s). In fact, that's what long mode (which comprises of two submodes: 64-bit and compatibility) is about. So unless Apple set out to do crazy/slow things, such as switching between long mode and legacy mode (which will be incredibly slow due to overhead) or running everything under ring 0 (unsafe), most likely the kernel modules all run under long mode and just that Apple elect to keep the driver management modules on 32-bit side to maintain compatibility. This is quite a feast and will require substantial assembly programming, regardless of monolithic or modular kernels. Memory management would have to use 64-bit paging paradigm (involving PML4) and the overhead will be similar or worse than a 32-bit OS using PAE.

Reply Parent Bookmark Score: 1