x86 - x64 porting query - windows

We have an application written in C/C++ code running on 32-bits windows with 32-bit Hardware. My question is that if we upgrade our hardware to 64-bit and keep our OS 32-bit, does my application need a port to 64-bit? If it requires, what benefits will be there on a 32 bit OS?

Hardware doesn't count -- the OS does. Ergo:
32 bit hardware with 32 bit OS will run only 32 bit ports
64 bit hardware with 32 bit OS will run only 32 bit ports
64 bit hardware with 64 bit OS will run both 32 bit and 64 bit ports
The advantage of recompiling for 64 bit is access to more than 3GB ram and a speed increase if you operate on 64 bit datatypes or take advantage of compiler intristics (and a few others, but do not count on a immedate gain).

If you keep the OS 32-bit, you must keep the app 32-bit, for many common values of OS. We, of course, cannot use telepathy to tell which OS you are using.

Related

Performance of 32 bit application on 64 bit platform

We have a 32 bit application. It is currently running on a 32 VM. If we run the application on a 64 bit OS(Virtual Machine) which supports Intel Virtualization Technology will it run faster? We do not have a 32 bit OS(Virtual Machine) which supports Intel Virtualization Technology.
There is not not enough material that I could find. Please share your knowledge.
The answer is no.
We were running on an instance which had no Hardware virtualization support. Now we tested on a new virtualized system with Intel Virtualization Technology. The Application here is a 32 bit system and the new system was 64 bit OS - Ubuntu. This was run using gcc-multilib support for Ubuntu. There was not a huge performance improvement observed.

Is Int64 supported on all Windows versions?

If I use a variable of type Int64, will it work on all Windows versions: win95, 98, 2000, nt, xp, vista, win7? No matter what OS it is 32bit or 64bit? And no matter what CPU they are using?
I just want to be sure, that my program will work on all Windows versions.
The size of datatypes provided by a language is not constrained by the operating system or hardware platform. I can have 64-bit integers on 32-bit platforms (or 16- or 8- or 11-bit, for that matter).
Int64 variables are supported by the 32 bit Delphi compiler. All operations on Int64 operands will give identical results no matter what platform (machine, OS etc.) the code executes on.
On 32 bit platforms the compiler has to use special routines to perform 64 bit arithmetic using the 32 bit machine instructions that are available. When targetting a 64 bit machine the compiler can use native 64 bit instructions. No matter, the end result is indistinguishable to you.
Note that if you execute a 32 bit Delphi executable on a 64 bit OS, you will still be using the 32 bit emulator, a.k.a. WOW64. From the perspective of the executable, you are running on a 32 bit machine. Unless you are using the new 64 bit compiler introduced in XE2, you will be producing 32 bit executables.
The 64bit integers will work fine on a 32bit operating system.
Performance gains in using these data types however will only come when using code compiled for a 64bit operating system - for this you would need Delphi XE2.
Meanwhile you have the benefits extra data capacity, but not extra execution speed (although this would not normally be a consideration for most applications).

Open in 32-bit mode

Under MacOS, you can change a little option for 32-bit executables called "Open in 32-bit mode". Wouldn't it work directly? And it works, but for some applications you had to select this option in order to run without problems. This was frequent in Safari, where some add-ons required a 32-bit environment.
I can't understand what makes an 32-bit executable not able to run directly in 64-bit, so what exactly changes in 32-bit mode?
This is really only of historical interest. In the transition period from 32 bit to 64 bit many apps were built as universal with 3 or sometimes even 4 architectures combined into one fat binary (aka "Universal Binary"), typically ppc, x86 and x86-64. In a 32 bit x86 environment the 32 bit x86 executable would be used. In a 64 bit x86-64 bit environment the 64 bit executable would be used. However in some cases you might want to use the 32 bit x86 executable even in a 64 bit x86-64 environment, e.g. in the case you mentioned where you have older plug-ins which are 32-bit only and can not be used with a 64 bit executable. Hence the option to launch an app in 32 bit mode.
Obviously a 32 bit app uses 32 bit APIs and has a 32 bit address space, whereas a 64 bit app has a 64 bit address space and uses 64 bit APIs.

32 bit applications on 64 bit OS ( windows )

I need some help understanding how 32 bit applications use memory on a 64 bit OS.
A 32 bit application can use 2 gb of memory on 64 bit OS, correct?
Does this mean that 3 32 bit applications running in parrallel could address 6 gb of memory...
Or do the 3 32 bit applications have to share the 2-4 gb of 32 bit memory that the os has?
Likewise, If I have a webservice that is compiled as 32 bits, running under IIS on a 64 bit machine. As long as a single request to that webservice always stays under 2gb of memory usage, is there any point in recompiling to 64 bit? My theory is that IIS creates a new process for each request, so the whole pool of processes will be able to make use of all the memory the 64bit machine has , 8 or 15 or 20 gig or whatever.
Let me know your thoughts, thanks
Yes, the total usage of all the 32-bit programs can exceed 2 GB. So yes you can have a bunch of 32-bit processes using all the memory in a 64-bit machine.
Actually, there's a compiler option that lets 32-bit programs use up to 3GB in Windows.
If performance isn't important, then there isn't much of a reason to use 64-bit.

Do 32 bit programs run relatively slower on 64 bit OS against when they are natively run in 32 bit OS?

I was reading about WOW 64 here
http://en.wikipedia.org/wiki/WOW64
and learnt that its a layer in 64 bit Windows OS to run 32 bit programs.
So can I assume that 32 bit programs run relatively slower on 64 bit OS against when they are natively run in 32 bit OS.
I can see the advantages of memory access of over 4 GB in 64 bit OS. But does this advantage necessarily offset the small overhead added by layer of WOW64 ? Are there any other advantages of 64 bit which offset this.
The main advantage of a 64-bit system is that it allows applications in 64-bit mode, which, in turn, is primarily useful if you need to access more than 4GB memory. If you have that requirement, using a 64-bit system is your only choice. Your application would be using 64-bit code, so WOW64 would not be used, and thus not cause problems.
If you don't really have the requirement to use more than 4GB of memory in a single process, it becomes debatable whether 64-bit Windows is really an improvement. You might need 64-bit Windows if you want to use more than 4GB of main memory at all (although you can also use PAE for that, which has its own disadvantages). Still, on a 64-bit system, you can run 64-bit applications. With AMD64 processors, 64-bit mode might be faster than native 32-bit mode, because the processor has more registers. Whether this slight gain outweighs the slight loss wrt. WOW64 depends on your application mix.
Personally, I think many people install 64-bit Windows because they don't fully understand the consequences of doing so, but feel they are on the safe side (which they may not, due to the lack of drivers).

Resources