Operating system's performance - operating-system

Will there be a difference in the performance of a 32 bit operating system running on 64 bit processor and a 32 bit operating system running on 32 bit processor?

Just realized this didn't specify x86. I don't know if any ARMv8 CPUs are slower in ARMv7 mode than a similar-cost ARMv7 CPU.
You can't really compare apples-to-apples, because there's no such thing as a 64-bit CPU that's exactly the same as a 32-bit CPU except for supporting 64-bit mode. There are always other microarchitectural changes, too. (Like from Pentium M to Core2 on Intel.)
If we're talking about x86, then no. A 64-bit capable x86 CPU is no worse at running 32-bit code. This is called "legacy mode", as opposed to "compat mode" (32-bit user-space under 64-bit OS), but they perform the same.
In fact, the only CPUs that can't run in x86-64 mode these days are old, slow, or both. e.g. using a 32-bit-only CPU means you're running on Pentium4, Pentium-M, or an old Atom! Or Athlon-XP. Or an embedded x86 like Geode.
This is the same reason that 32-bit software is still widely used under Windows (although usually under a 64-bit OS).
The option you didn't mention is the high-performance one: 64-bit OS on a 64-bit CPU, even if you want to run 32-bit user-space code.
Especially if you have more than 1 or 2GB of RAM, it's likely that your system will run faster with a 64-bit kernel. 32-bit kernels can use more RAM, but it's ugly and not as fast as if the kernel can have all physical memory mapped into kernel-space virtual memory. See Linus Torvald's comments on PAE (Physical-Address Extensions)
See the x86 tag wiki for more about how x86 CPUs perform, and how to optimize for them.

Yes because you wouldn't make full use of all those 64bits. If you have a 32bits OS than you will only use that and not 64. However, if you were to have 64bits OS than it will make full use of those bits.
Also, please have a look at:
https://www.howtogeek.com/194119/why-are-most-programs-still-32-bit-on-a-64-bit-version-of-windows/
and
http://www.osnews.com/story/5768

Related

Do UEFI BIOS and OS have to be of the same 32bit or 64bit?

Can 32bit UEFI BIOS work with 64bit OS or vice versa? I don't think it can, or at least it shouldn't. But it seems to be possible according to this thread.
For a CPU capable of both 32bit and 64bit, it's just a matter of operating mode I think. And I believe it's switchable. So is there any technical reason that makes it impossible or inappropriate for mixed OS/BIOS arch?
So, the short answer is: it depends on your architecture.
On x86 it is possible, if a little bit fiddly. A whole class of 64-bit devices shipping with 32-bit UEFI are supported out of the box by at least Debian's amd64 port (more info).
On ARM it is not, or rather 32-bit OS on 64-bit UEFI is technically possible (only would still require the operating system loader to be 64-bit), but even fiddlier than on x86. Launching a 64-bit operating system from 32-bit firmware is simply not supported by the architecture.

Why is "amd" written in many installers?

I have seen many installers like that of Python and Ubuntu which has "amd" on them. Why is that so? Can I run those programs on my laptop having intel cpu? Please explain to me in detail. Thanks :)
It's not just AMD, it's AMD64.
Linux/gcc's names for x86 architectures are: i386 for 32bit, and amd64 for 64bit.
AMD designed x86-64, and amd64 existed as a name for it before Intel's first ia-32e CPUs were released. (Yes, Intel made up their own name for it. Also note that ia-64 is Itanium, not x86-64.)
(See the x86 tag wiki for vendor manuals and assembly-language info).
You get your answer from the following excerpt from wikipedia.
x86-64 (also known as x64, x86_64 and AMD64) is the 64-bit version of
the x86 instruction set. It supports vastly larger amounts
(theoretically, 264 bytes or 16 exbibytes) of virtual memory and
physical memory than is possible on its 32-bit predecessors, allowing
programs to store larger amounts of data in memory.

What do x86_64, i386, ia64 and other such jargons stand for?

I frequently encounter these terms and am confused about them. Are they specific to the Processor, or the Operating System, or both?
I have Ubuntu 12.04 running on Intel i7 machine. So which one of them would apply for my case?
They are processor instruction set names:
i386 is the name of the 32-bit instruction set first implemented by Intel in the 386 processor. It became dominant thanks to dirt-cheap PC hardware.
x86-64 is the name of the AMD extension added to i386 to make it capable of executing 64-bit code. This is the one you have. It is highly compatible with i386 and will execute a 32-bit program as fast as an i386 processor.
ia64 is the name of the instruction set used in Itanium processors. The other 64-bit architecture that nobody uses anymore.
Those are cpu instruction sets. Apps installers are compiled to some subset of them. Here most difference is between 32bit(i386) and 64bits(x86_64 and ia64). You can not run app for 64bit on 32bit cpu but in reverse usually yes.
x86_64 (AMD64) cpu is most common instruction set as comes to 64bit cpu on desktop computer. It is from AMD which was few years earlier with their cpu which worked fine with x86(32-bits) instructions also.
ia64 (itanium) is from intel. Itanium works fast only with 64bits and is still used in industry.
Intel now uses x86_64 instructions from AMD due to its popularity in industry.
Sometimes key "amd" at installer package name is present and it is what you need for 64bit intel cpu.
i386 is quite old (Pentium times, pentium III has i686). To determine 32bits architecture(on desktop computers) also is used term x86 (aliases: IA-32, x86-32). There are also other architectures 32/64bit like ARM from smartphones.
Other cpu instruction sets can make compression, video coding/decoding, virtualization, random generators, security etc. to be faster and better. Windows 8 require PAE, NX, SSE2 (some of those are not present in ARM cpus so you have other version of Windows 8RT for them).
In hardware, x86_64 is a type of processor that can run both 32bit and 64bit applications just fine where ia64 runs 32bit applications SLOWER than any other CPU, as it is meant for 64bit only applications.
Moving on to the software side. I'm not sure about Ubuntu, but generally a 64bit Windows OS will allow you to use more than 3.3GBs of memory as well as the advantage of using your 64bit hardware to address memory better and have bigger than 2GB processes running. Usually on a 32bit, once an application reaches the 2GB limit, you'll get a OutOfMemory error from your application.
For a full article, refer to: http://en.wikipedia.org/wiki/64-bit_computing

Lightweight method to use Amd64 instructions under 32-bit Windows?

For some CPU-bound code using 64-bit variables, it is beneficial to use the Amd64 instruction set rather than x86. How can it be done under 32-bit Windows (e.g. Windows XP SP3)? Of course I assume a modern, Amd64-enabled CPU. I'm excluding the working but heavyweight method: running a full-blown 64-bit OS as a virtual machine, e.g. Ubuntu for Amd64 under Virtualbox.
I understand some assembly is needed, and there will restrictions, in particular addressing more memory than 32-bit Windows manages. But I'm thinking of purely computational tasks needing only a moderate amount of memory and no call to external functions.
There is no way to use Amd64 instructions (Long mode) in 32-bit general-purpose OS (without kernel modification/special drivers/hypervisor).
This is because:
1) to use native 64-bit instructions you need to switch into long mode. This is privileged action. 32-bit OS kernel can't continue to work if the CPU is switched into 64-bit mode, so you should switch back before entering a kernel
2) But kernel are often called asynchronously, for timer (scheduler) and other hardware interrupts (drivers). It will not save 64-bit registers nor change mode from long into protected.
May be it is possible to write special driver, which will do the 64-bit tasks on 32-bit OS, but such driver is more like 64-bit kernel and dynamic patcher of kernel. I know no one such solution.
You can only use MMX, SSE, SSE2, SSE3, AVX for accessing 64-bit ALU and registers of your CPU when running in 32-bit OS.
I can say, that Linux, some BSD, Mac OS X have a mode, when 64-bit kernel is used, but user-space software is 32-bit. In such case it will be possible to run both 32-bit and 64-bit applications, because kernel knows about 64-bit mode and can access 64-bit registers to do a task switch. As far as I know, MS Windows have not such mode itself (the W7 emulates 32bit mode, but this is called my MS as simulator so I assume it is not an in-kernel feature).
Other possibility (this is better, is your CPU has support of hardware virtualization), is to use 64-bit hypervisor (VMware/Xen, other overpriced solutions) with 32-bit and 64-bit guest OSes. VirtualBox is other option of using hypervisor, and it is free to use.
In general, running 64-bit code in a 32-bit OS kernel is going to be next to impossible, for the following reasons:
The 32-bit OS is unaware of the additional 64-bit registers (and upper 32-bits of the existing registers) and will not save them across task switches
The 32-bit OS is not prepared to enable 64-bit code execution. Enabling 64-bit code execution means switching to IA-32e paging (which requires an entirely different page table format) and setting CS.L = 1 and CS.D = 0 in the code segment descriptor in the GDT (or LDT). (See the IA-32 manuals, vol 3a/3b 5.2.1)
In principle, you may be able to workaround both problems by writing a new HAL for Windows, which operates in IA-32e mode, and switches to a 64-bit trampoline code segment to save and restore 64-bit registers. This is a rather complex task; take a look at the Windows DDK for details. You could also use an emulation approach, as VirtualBox and friends do, if your CPU supports VMX. But it would be much simpler to simply use a 64-bit OS from the start.

Question about 32-bit / 64-bit systems

Firstly, what is this called? Is this the system's "platform"? If I want to know if a system is 32-bit or 64-bit, do I ask what "platform" it is?
Next, is what I wrote below correct:
-A 64-bit processor can run a 64-bit operating system or a 32-bit operating system (with a loss of efficiency).
-A 32-bit processor can run a 32-bit operating system only.
If I want to know if a system is 32-bit or 64-bit, do I ask what "platform" it is?
"Platform" is an overloaded term that can mean a great many things. It can mean the CPU family: x86 platform, IA-64 platform, x86-64 platform, ARM platform, MIPS platform, SPARC platform, etc. It can mean the underlying operating system: Windows platform, Linux platform, Solaris platform, etc. It can mean a combination of these: Wintel platform (Windows + Intel). It can mean specific distributions: Debian platform, Slackware platform.
If you want to know if a system is 32-bit or 64-bit, ask if it's 32-bit or 64-bit. And make sure that you also check the CPU for compatibility for your purposes. ARM cores are 32-bit too, but you can't run Windows on them (at this time). SPARCs can be 64-bit, but you won't be running your copy of Microsoft Office on it, I'd wager.
A 64-bit processor can run a 64-bit operating system or a 32-bit operating system (with a loss of efficiency).
This depends very much on the processor. Intel's IA-64 chips can't run 32-bit operating systems because they don't really have 32-bit instructions (if memory serves). About the only way you could run a 32-bit OS on one is if you emulated a 32-bit CPU of some sort. This would suck performance-wise.
On the other hand the x86-64 chips can run 64-bit OSes or 32-bit OSes with no loss of performance at all for the latter (when compared to a pure x86, I mean). I'm running a 32-bit version of Ubuntu, for example, on an x86-64 chip without difficulties. Of course the 64-bit system will run faster than the 32-bit if the underlying software was written to take advantage of the expanded capabilities! (You'd be surprised how little it matters for most day-to-day tasks, though.)
A 32-bit processor can run a 32-bit operating system only.
Again, it all depends on the processor. An x86 (not x86-64) can run 32-bit OSes, but can also run 16-bit OSes right down to plain old MS-DOS. On the other hand, ARMs tend to be 32-bit only. (There are some ARM cores that have 16-bit instructions, but most do not, again if memory serves.)
I'd strike the part about "with a loss of efficiency". 64 bit processors can run 32 bit OS's just fine; with exception to Itanium which require special OS builds.
Efficiency has nothing at all to do with it.
To give a partial answer: 32-bit or 64-bit is part of the architecture. I guess it is part of the platform too, but you're more likely to make an expert think of the 32/64-bit distinction by talking about architecture.
Honestly, if you want to know whether a system is 32-bit or 64-bit, just ask, "32-bit or 64-bit?"
Assuming we mean on bare metal, the second statement is true. The verity of the first depends on the processor architectures. IA-64 processors cannot run IA-32 operating systems without emulation, whereas EM64T processors can.
If you want to know if a system is 32-bit or 64-bit, you could ask what "bitness" it is.
Whether the statements about 64-bit and 32-bit processors running 64-bit and 32-bit operating systems are true depends entirely on which processors and operating systems you are talking about. You won't have much success running Windows XP on an 64-bit Alpha or SPARC processor.