In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly analyzes the relevant knowledge points of what is the difference between 32-bit and 64-bit in Linux. The content is detailed and easy to understand, and the operation details are reasonable, which has a certain reference value. If you are interested, you might as well follow the editor and learn more about "what's the difference between 32-bit and 64-bit in Linux".
In the field of general PC, whether in windows or Linux, we often hear the words "32-bit" and "64-bit". Similarly, there are "x86" and "x86x64", "i386" and "amd64". What are the connections and differences between these two groups of concepts?
In fact, these two sets of concepts involve three levels: hardware, system and software.
1. Hardware
Early intel processors, such as i386 486 and Pentium's CPU architecture, were 32-bit (32-bit registers, 32-bit virtual address space), collectively referred to as x86 architecture.
With the development of technology, 32-bit CPU has been unable to meet the demand. CPU,intel with 64-bit architecture developed by intel and AMD uses a completely different IA64 architecture from x86. Because it is completely incompatible with the original x86, it has not been applied in the field of PC, only in the field of servers.
The architecture developed by AMD is called amd64 (expand the register to 64-bit and support 64-bit virtual address), which is fully compatible with x86 instruction set and can run the old operating system and application software without any modification. It has been widely used in the PC world. Now almost all the CPU used for PC in the market support amd64 instruction set.
Of course, intel quickly developed a CPU that supports this instruction set, but intel called it the x64 architecture rather than the name amd64. In linux, it is called x86x64, which is the 64-bit extension of x86 architecture.
A detailed description of x86x64 can be found in the book in-depth understanding of computer Systems.
A way to see if CPU is 64-bit in linux: if the flags field in / proc/cpuinfo contains "lm", you are using 64-bit CPU (run the "grep 'lm' / proc/cpuinfo" command and the output is not empty).
2. System
The system can also be divided into 32-bit and 64-bit. Before the emergence of CPU with x86 and 64 architecture, PC operating systems used 32-bit operating systems, such as windows 2000 windows XP, then unix,linux and so on.
After the emergence of the x86 / 64 architecture, there are two versions of the system: 32-bit and 64-bit. The main difference between the two lies in the operations related to the hardware architecture.
Because the x86 64 architecture is fully compatible with the x86 architecture, the 32-bit system can run on the x86 64-bit, but it only uses the x86 part and does not give full play to the function of the hardware.
The 64-bit system is specially developed for 64-bit extension functions, in order to maximize the power of the hardware, it can not run on the cpu of x86 architecture.
In addition, whether it is windows or linux, the driver needs to be loaded into kernel space, so its type (32-bit or 64-bit) needs to be exactly the same as the system.
The relationship between the system and CPU is shown in the following figure:
The way to check whether the linux system is 32-bit or 64-bit: execute the shell command "arch", which shows that the current system is 64-bit, and that the system is 32-bit, such as i386 and i486.
3. Software
The application software running on the system can also be divided into 32-bit and 64-bit. The old application software runs in 32-bit CPU and 32-bit system, which belongs to 32-bit software.
After the advent of 64-bit systems, there are also native 64-bit programs that run exclusively on 64-bit systems and can make the most of the extended functions of 64-bit systems.
For C programs, the biggest difference between 64-bit programs and 32-bit programs is that the length of int,long and pointer data types are 64-bit, and 64-bit virtual address space can be used.
In fact, it is much more than that. when translating 64-bit C programs into assembly language or machine language, the compiler will try to use the registers of 64-bit processors and avoid accessing memory as much as possible, such as giving priority to function parameters and local variables in registers. not in the user stack.
In addition, in 64-bit systems, in order to be compatible with a large number of old applications, the system will add a virtual layer to translate x86 instructions, so that 32-bit programs can also run on 64-bit systems (both windows and linux support).
Similarly, in a 64-bit system, you can generally choose to compile to a 32-bit program using a 64-bit compiler (gcc compiles into a 32-bit executable file using-M32).
In addition, on PC, whether the software can run depends on whether the system supports it or not, regardless of the architecture of CPU. The relationship between the software and the system is shown in the following figure:
A way to see whether an executable file is 32-bit or 64-bit in linux: execute the shell command "file / usr/bin/xxx", and if it is a 32-bit program, it is displayed as "ELF 32-bit..." If it is 64-bit, it is displayed as "ELF 64-bit …" .
4. Linux distribution and kernel
In linux distributions, different installation CDs are generally released for different architectures. Take debian as an example, i386 and amd64 are available for PC.
As described above, both versions of the system can be installed on machines that use 64-bit CPU, while machines that use 32-bit CPU can only install the i386 version of the system.
The kernels and software packages included in debian amd64 are all 64-bit versions, while debian i386 has 32-bit and 64-bit kernels, as well as 32-bit software, probably considering that some users want to use 64-bit kernels to run 32-bit programs.
There is no 32-bit or 64-bit kernel source code, and you can use the ARCH parameter to manually specify which architecture to compile into when compiling the kernel. For example: "make ARCH=i386 menuconfig", "make ARCH=i386" for configuration, compile 32-bit kernel
"make ARCH=x86_64 menuconfig" and "make ARCH=x86_64" are used to configure and compile 64-bit kernels.
However, the 32-bit kernel compiled on a debian amd64 CD-ROM installation cannot be booted, because all software packages installed on the system are native 64-bit programs that cannot run on the 32-bit kernel. A typical error is that you cannot find a running init program when prompted to boot.
64-bit kernels compiled on systems installed with the debian i386 CD can be used, but you need to add IA32 Emulation support when configuring the kernel (menuconfig: "Executable file formats/Emulations"-> "IA32 Emulation").
For this reason, the system I installed on the debian amd64 CD I built is now installed on the debian i386 CD, so that I can compile the new 32-bit and 64-bit official kernels at the same time for comparative testing.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
On the "what is the difference between 32-bit and 64-bit in Linux", this is the end of the introduction, more related content can be searched for previous articles, hope to help you answer questions, please support the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.