64 bits cpus

Discussion of chess software programming and technical issues.

Moderator: Ras

hcyrano

Re: 64 bits cpus

Post by hcyrano »

schlucke
Posts: 58
Joined: Thu Apr 09, 2009 1:38 pm

Re: 64 bits cpus

Post by schlucke »

Evert wrote:
bob wrote: Again, this is irrelevant. The issue is that the 64 bit processors operate in a different mode, and you need a 64-bit aware kernel to make the processor function. Normal X86 uses a 2-level page table for virtual-to-real translations, 64 bit uses a 4-level page table. A 32 bit OS is simply going to run in 32 bit mode to use the page table approach it is aware of. If it becomes aware of the 64 bit format, then it is no longer a 32 bit OS.
I'd agree with you, except that OS X by default boots into a 32 bit kernel (you can make it boot into a 64 bit kernel, but you have to do this explicitly) and runs 64 bit applications just fine (experimentally verified by compiling code in 64 bit mode).

I have no idea what Apple do to make this work. Maybe what they're doing is running key aspects of the kernel in 64 bit and run the main part of the kernel in 32 bit, translating system calls into the 64 bit kernel into equivalent calls into the 32 bit kernel.
That, or the system really does boot into 64 bit but Apple have decided for obscure reasons to tell everyone that it is still booting in 32 bit mode...
We had the same situation in AIX a while back on POWER CPUs. The trick is that the major parts of the kernel are still 32bit, but the VMM is 64bit. And yes, the kernel must tranclate adresses between 64 and 32 bits during system calls, but that works well.

Apple is doing this (as IBM years ago), because the most existing device drivers are still 32bit. They would not run in a "true" 64bit kernel. Over the time all drivers will be ported to 64bit .... and than you can switch to a "true" 64 bit kernel.
hcyrano

Re: 64 bits cpus

Post by hcyrano »

100% right

then ?

64 bits application on 32 bits Os is unpossible?
schlucke
Posts: 58
Joined: Thu Apr 09, 2009 1:38 pm

Re: 64 bits cpus

Post by schlucke »

hcyrano wrote:100% right

then ?

64 bits application on 32 bits Os is unpossible?
Depends on how you define 32bit OS?

For me AIX 5.x and the new Snow Leopard are true 64bit OSes, because they boot up with setting the CPUs to 64bit mode and have a 64bit VMM. That is all you need to run run 64bit apps. So they are not 32bit OSes!

And Bob is right: If you boot the CPUs in 32bit mode and don't have a 64bit VMM, it is impossible to run 64 bit applications.
hcyrano

Re: 64 bits cpus

Post by hcyrano »

and leopard or tiger?
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: 64 bits cpus

Post by bob »

hcyrano wrote:tiger is 32 bits right?

then
http://developer.apple.com/macosx/64bit.html
Not according to the link you gave. A 32 bit O/S can only address 4 gigabytes of memory. To go farther, you step into the 64 bit world.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: 64 bits cpus

Post by bob »

Evert wrote:
bob wrote: Again, this is irrelevant. The issue is that the 64 bit processors operate in a different mode, and you need a 64-bit aware kernel to make the processor function. Normal X86 uses a 2-level page table for virtual-to-real translations, 64 bit uses a 4-level page table. A 32 bit OS is simply going to run in 32 bit mode to use the page table approach it is aware of. If it becomes aware of the 64 bit format, then it is no longer a 32 bit OS.
I'd agree with you, except that OS X by default boots into a 32 bit kernel (you can make it boot into a 64 bit kernel, but you have to do this explicitly) and runs 64 bit applications just fine (experimentally verified by compiling code in 64 bit mode).

I have no idea what Apple do to make this work. Maybe what they're doing is running key aspects of the kernel in 64 bit and run the main part of the kernel in 32 bit, translating system calls into the 64 bit kernel into equivalent calls into the 32 bit kernel.
That, or the system really does boot into 64 bit but Apple have decided for obscure reasons to tell everyone that it is still booting in 32 bit mode...
If you boot two different kernels, then this discussion is moot. A 32 bit kernel can not run 64 bit applications, nor use all the 64 bit hardware (including expanded address space) as I mentioned. No operating-system savvy person would say a system is 32 bits if you can boot either of two kernels, where one is 32 bits and one is 64 bits. We have been able to do that under linux forever also, but when you boot the 32 bit kernel, you are stuck with 32 bit limitations.

As far as your second paragraph, it is obvious what they are doing. You boot one of two kernels. You have two different O/S kernels on the box. You can run either but not both at the same time. This has absolutely nothing to do with the 32 vs 64 bit discussion. Anyone can do this. You can even dual-boot windows and have a 32 bit version and a 64 bit version on the same machine. But when you boot, you have to choose which, and you are stuck with that choice until you reboot.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: 64 bits cpus

Post by bob »

hcyrano wrote:100% right

then ?

64 bits application on 32 bits Os is unpossible?
Again, absolutely impossible. Unless the OS is 64 bit aware. In which case no one calls it a 32 bit kernel. Even if pieces of it run in 32 bit mode, which is fine. But you _must_ have the necessary support for the 64 bit hardware or nothing works. We've always been able to run 32 bit stuff on 64 bit kernels, but never vice-versa.
Evert

Re: 64 bits cpus

Post by Evert »

bob wrote: If you boot two different kernels, then this discussion is moot. A 32 bit kernel can not run 64 bit applications, nor use all the 64 bit hardware (including expanded address space) as I mentioned. No operating-system savvy person would say a system is 32 bits if you can boot either of two kernels, where one is 32 bits and one is 64 bits. We have been able to do that under linux forever also, but when you boot the 32 bit kernel, you are stuck with 32 bit limitations.
Yes, I know - I do, in fact, know how computers work, thanks.
As I said, I'd agree with you except that I know I can run 64 bit applications on what Apple calls a 32-bit kernel.
You boot one of two kernels.
That's right. The 32 bit one (or what Apple calls the 32 bit one), unless you do something to explicitly request the 64 bit one.
This has absolutely nothing to do with the 32 vs 64 bit discussion.
It does in the sense that you have a choice in which kernel to boot - and the 32 bit one is the default.
You can even dual-boot windows and have a 32 bit version and a 64 bit version on the same machine. But when you boot, you have to choose which, and you are stuck with that choice until you reboot.
Yes, I know. I used to have a dual boot setup of Windows and Linux, except I never booted into Windows. Same thing.

I'll repeat what I said: I know for a fact that I can run 64 bit applications on my Mac. My initial conclusion was that the OS is running in 64 bit. I now know that it boots into what Apple calls a 32 bit kernel. This is either a lie for reasons I cannot even begin to imagine, or it's a question of semantics, where the OS at its core is 64 bit but runs essential parts of the kernel in 32 bit (see for another reply to this idea). I suspect it's the latter, in which case it's down to semantics to what you'd call a 32 bit and what you'd call a 64 bit OS.

Perhaps the marketing term is "64 bit enabled" or "64 bit ready".
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: 64 bits cpus

Post by bob »

Evert wrote:
bob wrote: If you boot two different kernels, then this discussion is moot. A 32 bit kernel can not run 64 bit applications, nor use all the 64 bit hardware (including expanded address space) as I mentioned. No operating-system savvy person would say a system is 32 bits if you can boot either of two kernels, where one is 32 bits and one is 64 bits. We have been able to do that under linux forever also, but when you boot the 32 bit kernel, you are stuck with 32 bit limitations.
Yes, I know - I do, in fact, know how computers work, thanks.
As I said, I'd agree with you except that I know I can run 64 bit applications on what Apple calls a 32-bit kernel.
And I _know_ that you can _not_ run 64 bit applications unless the kernel is _actually_ 64 bits aware. Regardless of whatever nonsense Apple or you are referencing. If the kernel works on 64 bit hardware, and _uses_ the 64 bit hardware, it is, by definition, a 64 bit kernel. I don't care if there are 32 bit drivers loaded. That's irrelevant. I've already said it is trivial to run 32 bit stuff on a 64 bit kernel.

But if it runs 64 bit apps, it _is_ a 64 bit kernel. Otherwise it has absolutely no chance of running since the 64 bit virtual memory hardware is completely incompatible with the way this is done in the 32 bit world.
You boot one of two kernels.
That's right. The 32 bit one (or what Apple calls the 32 bit one), unless you do something to explicitly request the 64 bit one.
This has absolutely nothing to do with the 32 vs 64 bit discussion.
It does in the sense that you have a choice in which kernel to boot - and the 32 bit one is the default.
Fine, but what does that have to do with the original question "Can you run a 64 bit application on a 32 bit operating system?" The answer was, and still is, "no". Being able to run both is really nonsensical. Who in their right mind would take a good 64 bit machine and cripple it with a 32 bit operating system? You lose 8 registers. You lose the ability to use more than 4 gigs of ram. Etc. But if you insist, you can run either a 32 or 64 bit linux system, or a 32 or 64 bit windows system, and dual-boot either so that you run what you want, for whatever reason you want.

This is not unique to Apple.




You can even dual-boot windows and have a 32 bit version and a 64 bit version on the same machine. But when you boot, you have to choose which, and you are stuck with that choice until you reboot.
Yes, I know. I used to have a dual boot setup of Windows and Linux, except I never booted into Windows. Same thing.

I'll repeat what I said: I know for a fact that I can run 64 bit applications on my Mac. My initial conclusion was that the OS is running in 64 bit. I now know that it boots into what Apple calls a 32 bit kernel. This is either a lie for reasons I cannot even begin to imagine, or it's a question of semantics, where the OS at its core is 64 bit but runs essential parts of the kernel in 32 bit (see for another reply to this idea). I suspect it's the latter, in which case it's down to semantics to what you'd call a 32 bit and what you'd call a 64 bit OS.

Perhaps the marketing term is "64 bit enabled" or "64 bit ready".
It is simply a false statement. Any person with any operating system development experience will echo what I stated exactly. The definition of a 64 bit operating system is simple. If you put the CPU in 64 bit mode, you _must_ be a 64 bit O/S or else it will instantly crash when that mode switch is done. Why Apple is making those kinds of statements is beyond me. And wrong to boot. Not the first time nor will it be the last time.