📜 ⬆️ ⬇️

64 bits


The article reveals the meaning of the term "64 bits." The article briefly describes the history of the development of 64-bit systems, describes the most common 64-bit Intel 64 -bit processors and the 64-bit Windows operating system.


Introduction


In the framework of computer architecture, the term "64-bit" means 64-bit integers and other types of data having a size of 64 bits. “64-bit” systems can be understood as 64-bit microprocessor architectures (for example, EM64T, IA-64) or 64-bit operating systems (for example, Windows XP Professional x64 Edition). You can talk about compilers that generate 64-bit program code.

This article will discuss various issues related to 64-bit technologies. The article is intended for programmers who want to start developing 64-bit programs , and is aimed at Windows developers, since for them the issue of familiarity with 64-bit systems is the most relevant.
')

64-bit systems history


64 bits just recently entered the lives of most users and application programmers. However, working with 64-bit data has a long history.

1961: IBM launches the IBM 7030 Stretch supercomputer, which uses 64-bit data words, 32-bit or 64-bit machine instructions.

1974: Control Data Corporation launches the CDC Star-100 vector supercomputer, which uses the architecture of 64-bit words (previous CDC systems had a 60-bit architecture).

1976: Cray Research launches the first Cray-1 supercomputer, which implements the architecture of 64-bit words and will serve as the basis for all subsequent Cray vector supercomputers.

1985: Cray releases UNICOS, the first 64-bit implementation of the Unix operating system.

1991: MIPS Technologies manufactures the first 64-bit processor, the R4000, which implements the third modification of the MIPS architecture developed by their company. This processor has been used in SGI graphics workstations since the IRIS Crimson model. Kendall Square Research launches its first KSR1 supercomputer, built on the basis of their own patented 64-bit RISC architecture under OSF / 1.

1992: Digital Equipment Corporation (DEC) introduces the full 64-bit Alpha architecture, the brainchild of the PRISM project.

1993: DEC releases the 64-bit Unix-like operating system DEC OSF / 1 AXP (later renamed Tru64 UNIX) for its systems built on the Alpha architecture.

1994: Intel announces plans to develop the 64-bit IA-64 architecture (with Hewlett-Packard), the successor to their 32-bit IA-32 processors. The release date is scheduled for 1998-1999. SGI releases IRIX 6.0 with 64-bit support for the R8000 chipset.

1995: Sun launches the SPARC UltraSPARC 64-bit processor. HAL Computer Systems, subordinate to Fujitsu, launches workstations based on the first generation 64-bit SPARC64 processor, independently developed by HAL. IBM releases A10 and A30 microprocessors, as well as 64-bit PowerPC AS processors. IBM also releases a 64-bit update for the AS / 400 system, which can convert operating systems, databases, and applications.

1996: Nintendo introduces the Nintendo 64 game console, based on the cheaper version of the MIPS R4000. HP releases the implementation of the 64-bit 2.0 version of its own PA-RISC PA-8000 architecture.

1997: IBM launches RS64 line of 64-bit PowerPC / PowerPC AS processors.

1998: Sun releases Solaris 7 with full 64-bit UltraSPARC support.

1999: Intel releases the IA-64 instruction set. AMD publicly announces its set of 64-bit extensions for IA-32, which was named x86-64 (later renamed AMD64).

2000: IBM launches its first zSeries z900 64-bit mainframe, compatible with ESA / 390, as well as a new z / OS operating system.

2001: Intel finally launches a line of 64-bit processors, which are now called Itanium and designed for high-performance servers. The project does not meet expectations due to numerous delays in the release of IA-64 to the market. NetBSD becomes the first operating system to run on an Intel Itanium processor after it is released. In addition, Microsoft also releases Windows XP 64-Bit Edition for the IA-64 architecture of the Itanium family, although it still has the ability to run 32-bit applications using the WoW64 layer.

2003: AMD introduces the Opteron and Athlon 64 processor lines, based on the AMD64 architecture, which is the first 64-bit processor architecture based on the x86 architecture. Apple is starting to use an IBM PowerPC 970 64-bit G5 processor. Intel claims that the Itanium processor chips will remain the only 64-bit processors developed by their company.

2004: In response to AMD’s commercial success, Intel admits that they developed a clone of AMD64 extensions, which was given the name IA-32e (later renamed EM64T, and then again Intel 64). Intel also releases updated versions of the Xeon and Pentium 4 processor families with support for new commands.

2004: VIA Technologies introduces its 64-bit Isaiah processor.

2005: January 31, Sun releases Solaris 10 with support for AMD64 / Intel 64 processors. April 30, Microsoft releases Windows XP Professional x64 Edition for AMD64 / Intel 64 processors.

2006: Sony, IBM and Toshiba launch the 64-bit Cell processor for the PlayStation 3, servers, workstations and other devices. Microsoft is releasing Windows Vista with a 64-bit version enabled for AMD64 / Intel 64 processors, which supports 32-bit compatibility. All Windows applications and components are 64-bit, but many of them have 32-bit versions included in the system as plug-ins for compatibility.

2009: Like Windows Vista, Microsoft’s Windows 7 includes the full 64-bit version for AMD64 / Intel 64 processors, and the 64-bit version is installed by default on most new computers. The Apple Mac OS X 10.6 operating system, Snow Leopard, which has a 64-bit kernel and is intended for AMD64 / Intel 64 processors, however, by default, this system is installed only on some of the latest Apple computer models. Most applications shipped with Mac OS X 10.6 are now also 64-bit.

For more information on the history of development of 64-bit systems, see the article by John Masha "The Long Road to 64-bits " [1] and in the encyclopedic article in Wikipedia " 64-bit " [2].

Application programming and 64-bit systems


At the time of writing this article in 2010, two 64-bit microprocessor architectures are the most well-known and widespread: IA64 and Intel 64.
  1. IA-64 64-bit microprocessor architecture developed jointly by Intel and Hewlett Packard. It is implemented in Itanium and Itanium 2 microprocessors. For a more detailed acquaintance with the IA-64 architecture, you can refer to the following Wikipedia articles: " IA-64 ", " Itanium ", " Itanium 2 ". Itanium architecture is supported by a large number of server manufacturers: Bull, Fujitsu, Fujitsu Siemens Computers, Hitachi, HP, NEC, SGI and Unisys. These manufacturers have joined Intel and a number of software developers to create the Itanium Solutions Alliance in order to promote the architecture and accelerate the pace of software porting.
  2. Intel 64 (AMD64 / x86-64 / x64 / EM64T) - this architecture is an extension of the x86 architecture with full backward compatibility. There are many variants of the name of this architecture, which leads to confusion, although, in fact, all these names denote the same: x86-64, AA-64, Hammer Architecture, AMD64, Yamhill Technology, EM64T, IA-32e, Intel 64, x64 You can learn more about how so many names appeared in the article from Wikipedia: " X86-64 ". Intel 64 processors have found widespread personal computers. And most likely your computer is equipped with a processor with this architecture.
It is important to understand that IA-64 and Intel 64 (AMD64) are completely different, incompatible with each other, microprocessor architectures. Further in the article we will consider only the architecture of Intel 64 (x64 / AMD64), as more popular among developers of application software for the Windows operating system. For brevity, the Intel 64 software model available to a programmer on a 64-bit Windows system is called Win64 .

Intel 64 Architecture (AMD64)


The Intel 64 architecture in question is a simple, yet powerful, backward-compatible extension of the outdated x86 industrial architecture. It adds 64-bit address space and expands register resources to support higher performance of recompiled 64-bit programs. The architecture provides support for outdated 16-bit and 32-bit code of applications and operating systems without modifying or recompiling them.

A distinctive feature of Intel 64 is the support of sixteen 64-bit general-purpose registers (there were eight 32-bit registers in x86-32). 64-bit arithmetic and logical operations on integers are supported. 64-bit virtual addresses are supported. For addressing new registers for commands, “register expansion prefixes” are entered, for which the range of 40h-4Fh codes used for the INC <register> and DEC <register> commands in 32- and 16-bit modes has been selected. The INC and DEC commands in 64-bit mode should be encoded in a more general, two-byte form.

Registers:

16 integer 64-bit general purpose registers (RAX, RBX, RCX, RDX, RBP, RSI, RDI, RSP, R8 - R15),
8 80-bit floating point registers (ST0 - ST7),
8 64-bit Multimedia Extensions registers (MM0 - MM7, have a common space with registers ST0 - ST7),
16 128-bit SSE registers (XMM0 - XMM15),
64-bit RIP pointer and 64-bit RFLAGS flags register.

The need for a 64-bit architecture is determined by applications that need a large address space. First of all, these are high-performance servers, database management systems, CAD systems and, of course, games. Such applications will receive significant advantages from 64-bit address space and an increase in the number of registers. The small number of registers available in the outdated x86 architecture limits the performance of computational tasks. The increased number of registers provides sufficient performance for many applications.

Let us emphasize the main advantages of the x86-64 architecture:

64-bit operating systems


Virtually all modern operating systems now have versions for Intel 64 architecture. For example, Microsoft provides Windows XP x64. The largest developers of UNIX systems also provide 64-bit versions, such as Linux Debian 3.5 x86-64. However, this does not mean that all the code of such a system is fully 64-bit. Some of the OS code and many applications may well remain 32-bit, since Intel 64 provides backward compatibility with 32-bit applications. For example, the 64-bit version of Windows uses a special WoW64 mode (Windows-on-Windows 64), which translates calls of 32-bit applications to resources of a 64-bit operating system.

Further in the article we will consider only 64-bit operating systems of the Windows family.

Wow64


Windows-on-Windows 64-bit (WoW64) is a subsystem of the Windows operating system that allows you to run 32-bit applications on all 64-bit versions of Windows.

The WoW64 subsystem does not support the following programs:

There are differences WoW64 depending on the processor architecture. For example, a 64-bit version of Windows designed for the Intel Itanium 2 processor uses WoW64 to emulate x86 instructions. Such emulation is quite resource-intensive compared to the Intel 64 architecture for WoW64, since it switches from 64-bit mode to compatibility mode when running 32-bit programs.

WoW64 on Intel 64 architecture (AMD64 / x64) does not require instruction emulation. Here, the WoW64 subsystem emulates only a 32-bit environment, at the expense of an additional layer between the 32-bit application and the 64-bit Windows API. Somewhere this layer is thin, somewhere not very. For an average program, the loss in productivity due to the presence of such an interlayer will be about 2%. For some programs, this value may be greater. Two percent is not much, but keep in mind that 32-bit applications run a bit slower under the 64-bit Windows operating system than in a 32-bit environment.

Compiling 64-bit code not only eliminates the need for WoW64, but also gives an additional performance boost. This is due to architectural changes in the microprocessor, such as an increase in the number of general-purpose registers. For an average program, you can expect a performance gain of 5–15% from a simple recompilation.

Due to the presence of the WoW64 layer, 32-bit programs work less efficiently in a 64-bit environment than in a 32-bit one. But still, simple 32-bit applications can get one advantage from running them in a 64-bit environment. You probably know that a program compiled with the / LARGEADDRESSAWARE: YES key can allocate up to 3 gigabytes of memory if the 32-bit Windows operating system is running with the / 3gb key. So, the same 32-bit program running on a 64-bit system can allocate almost 4 GB of memory (in practice, about 3.5 GB).

The WoW64 subsystem isolates 32-bit programs from 64-bit programs by redirecting calls to files and the registry. This prevents the random access of 32-bit programs to the data of 64-bit applications. For example, a 32-bit application that runs a DLL file from the% systemroot% \ System32 directory may accidentally refer to a 64-bit DLL file that is incompatible with a 32-bit program. To avoid this, the WoW64 subsystem redirects access from the% systemroot% \ System32 folder to the% systemroot% \ SysWOW64 folder. This redirection helps prevent compatibility errors, since it requires a DLL file created specifically for working with 32-bit applications.

More details on file system and registry redirection mechanisms can be found in the MSDN section " Running 32-bit Applications ".

Win64 software model


As in Win32, the size of pages in Win64 is 4Kb. The first 64KB of the address space is never displayed, that is, the smallest correct address is 0x10000. Unlike Win32, system DLLs are loaded above 4GB.

The special feature of compilers for Intel 64 is that they can most effectively use registers to pass parameters to functions, instead of using the stack. This allowed the Win64 architecture developers to get rid of such a thing as a calling convention. In Win32, you can use different conventions: __stdcall, __cdecl, __fastcall, and so on. Win64 has only one calling convention. Consider an example of how four arguments of integer type are passed in registers:
Arguments after the first four integers are passed on the stack. For float arguments, the XMM0-XMM3 registers are used, as well as the stack.

The difference in calling conventions leads to the fact that in one program you cannot use both 64-bit and 32-bit code. In other words, if the application is compiled for 64-bit mode, then all used libraries (DLL) must also be 64-bit.

Parameter passing through registers is one of the innovations that make 64-bit programs more productive than 32-bit ones. Additional performance gains can be obtained using 64-bit data types.

Address space


Although a 64-bit processor can theoretically address 16 exabytes of memory (2 ^ 64), Win64 currently supports 16 terabytes (2 ^ 44). There are several reasons for this. Current processors can provide access to only 1 terabyte (2 ^ 40) of physical memory. The architecture (but not the hardware) can extend this space up to 4 petabytes (2 ^ 52). However, in this case, you need a huge amount of memory for page tables that display memory.

In addition to these limitations, the amount of memory that is available in a particular version of the 64-bit Windows operating system also depends on commercial considerations of Microsoft. Below is information on the amount of memory supported by different versions of 64-bean versions of Windows:

Windows XP Professional - 128 Gbyte;
Windows Server 2003, Standard - 32 Gbyte;
Windows Server 2003, Enterprise - 1 Tbyte;
Windows Server 2003, Datacenter - 1 Tbyte;
Windows Server 2008, Datacenter - 2 Tbyte;
Windows Server 2008, Enterprise - 2 Tbyte;
Windows Server 2008, Standard - 32 Gbyte;
Windows Server 2008, Web Server - 32 Gbyte;
Vista Home Basic - 8 Gbyte;
Vista Home Premium - 16 Gbyte;
Vista Business - 128 Gbyte;
Vista Enterprise - 128 Gbyte;
Vista Ultimate - 128 Gbyte;
Windows 7 Home Basic - 8 Gbyte;
Windows 7 Home Premium - 16 Gbyte;
Windows 7 Professional - 192 Gbyte;
Windows 7 Enterprise - 192 Gbyte;
Windows 7 Ultimate - 192 Gbyte;

64-bit application development


64-bit application development issues are most fully covered in the course " Lessons on developing 64-bit C / C ++ applications ". Content:

Lesson 01. What is 64-bit systems .
Lesson 02. Support for 32-bit applications .
Lesson 03. Porting code to 64-bit systems. Pros and cons .
Lesson 04. Creating a 64-bit configuration .
Lesson 05. Building a 64-bit application .
Lesson 06. Errors in 64-bit code .
Lesson 07. Problems of detecting 64-bit errors .
Lesson 08. Static analysis to detect 64-bit errors .
Lesson 09. Pattern 01. Magic numbers .
Lesson 10. Pattern 02. Functions with a variable number of arguments .
Lesson 11. Pattern 03. Shift operations .
Lesson 12. Pattern 04. Virtual functions .
Lesson 13. Pattern 05. Address arithmetic .
Lesson 14. Pattern 06. Change the type of array .
Lesson 15. Pattern 07. Packing pointers .
Lesson 16. Pattern 08. Memsize-types in associations .
Lesson 17. Pattern 09. Mixed arithmetic .
Lesson 18. Pattern 10. Storing integer values ​​in double .
Lesson 19. Pattern 11. Serialization and data exchange .
Lesson 20. Pattern 12. Exceptions .
Lesson 21. Pattern 13. Data alignment .
Lesson 22. Pattern 14. Overloaded functions .
Lesson 23. Pattern 15. Growth of size of structures .
Lesson 24. Phantom errors .
Lesson 25. Practical acquaintance with patterns of 64-bit errors .
Lesson 26. Optimization of 64-bit programs .
Lesson 27. Features of creating installers for 64-bit environments .
Lesson 28. Estimation of the cost of the process of 64-bit migration of C / C ++ applications .

I also recommend a section with reviews of articles related to 64-bit technologies.

Bibliographic list

  1. John R. Masha. Long road to 64 bits. http://www.viva64.com/go.php?url=321
  2. Wikipedia. 64-bit. http://www.viva64.com/go.php?url=203

Source: https://habr.com/ru/post/93831/


All Articles