当前位置:网站首页>Do you use 32-bit or 64 bit? What's the difference?

Do you use 32-bit or 64 bit? What's the difference?

2020-12-07 08:51:31 Dragon jump 12

This article has been included in my GitHub, Welcome to star and issues.

https://github.com/midou-tech/articles

Through the study of the previous two articles , My nephew is curious about computers , I almost took my computer apart for research

I think this kind of learning spirit is very good , If she really broke the computer , I agree with you , After all, this kind of learning experience is in

Just a few days ago, my nephew and I complained that as long as the application opens more or the web page opens more , Computers are super slow , Caton half a day

I asked with my backhand , You know why ?

She pretended to be ignorant and said I do not know!

I talked about the reasons of Caton in detail :

  • The open app Or the web page needs to calculate too much data , Computer Lack of calculation power , At this time, all the computing power of the computer has been expropriated , Can't operate other
  • The open app Large memory requirements , open app More or less app Memory requirements are high , Will cause the memory to fill up , This happens disk and Memory In exchange for , Disk speed is very slow
  • app Need to read a lot of disk data , Disk read and write speed is much lower than memory and CPU
  • Network stuck ,app There's Internet Interaction , The Internet is very slow ,app Will experience Overtime and retry

Balabala said something , She can't help it , Cut in

I looked at the task manager , Memory when stuck house full 100% state , And then we added Memory module , Strangely enough, things are not getting better , It really puzzles me .

 question mark ?
question mark ?

I hear this , We already know where the disease is ,32bit and 64bit The problem of , Today I will tell you about this disease

 Outline of the article
Outline of the article

32bit and 64bit What does it mean ?

I remember the interview time , Often asked by the interviewer , You know, 32 Bit and 64 What's the difference between the two ?

At that time, I blurted out Addressing capabilities are different

Now it seems , The answer is vague 、 Right or wrong

First , We should ask clearly 32 Bit and 64 Position refers to Software Well ? still CPU Well ?

Like the nephew's description above , She added a 4G Memory module , She originally had 4G Memory total 8G Memory , Why is the original memory problem still recurring ?

There are two possible reasons :

  1. her operating system The software is 32 position , however CPU yes 64 Bit , In this way , Even if the memory is added, it can't be used .

Although you have the ability , But it's limited space , It's just a waste , At this point, she pretended to be 64 Bit operating system You can play 8G The power of memory .

  1. 32 Bit CPU, In this way , Add memory to 8G 了 , To no avail , The addressing ability can't keep up with .

The above two situations , The first is the ability to , But it's limited , Just let me go , Just give you a piece of land ; The second is powerlessness

So when talking about 32 Bit and 64 It's a bit of a problem , It's a priority to figure out what's being said ?

It's easy to see from the above , To refer to Objects of different , It turns out to be completely Different Of , Can't be generalized

32bit and 64bit The difference between

got it 32 Bit and 64 Bits refer to objects , Now let's talk about the difference between the two , Before we talk about it, let's review what we said before Von Neumann structure

I don't want to talk about the five piece set of structure , There is a special introduction to How computers are made up of ?

  • input device

  • Output devices

  • Memory

  • a central processor

  • controller

Talk about how to communicate effectively between the five pieces

CPU And memory and other devices , Need to communicate , So we use a special device to control , Namely Bus .

The bus is divided into 3 Kind of :

  • Address bus , Special for designation CPU Memory address to be operated on
  • data bus , Used to read and write data in memory
  • Control bus , Used to send and receive key signals , Such as interrupt signals , And device reset 、 Ready to wait for the signal , It's all transmitted through the control bus .CPU You need to respond to these signals , This also requires a control bus .

Of course , And that's what we're going to say 32 Bit and 64 What does it matter ?

32 Bit and 64 The difference between bit Software

32 Bit software and 64 The difference between bit software is , The size of the pointer Different , That is to say Address range Different

A black question mark , Now high-level languages don't use the concept of pointers anymore , Uncle long is still saying The pointer Is it out of time

Yes , High level language except C++ Still talking about the pointer , Other languages such as java、Python、go I don't talk about pointers anymore

Language designers don't talk about it for developers alleviate excessive burden , It doesn't mean there's no more

The pointer is very core , Because we Access to memory data must depend on the address , The pointer is the address

It's back , Continue to say 32 Bit software and 64 Bit software problem

Software designers are 32 Bit , It means that the pointers used in the program are 4byte Of , It means the largest address you can find 2^32 Power , That is to say 4G.

So when our operating system is 32 When a , You can only access 4G Memory , No matter how much memory we add It's all meaningless

Make a statement The operating system is also a kind of software , It's just a kind of system software

User software depends on the addressing operation of the operating system , If the operating system is 32 position , This operating system does not work 64 Bit user software

We all know , Data transfer is through High and low voltage The control of the , High level is 1 The low level is 0

Uncle long used to do this kind of operation when he was studying digital circuit in University , To move is to connect a circuit adder

 Four bit full adder experiment
Four bit full adder experiment

Often doing experiments is to make a few chips Through the circuit to control to make an adder or go on the display according to the rules of the corresponding diode

Tell the truth , Freshman asked me to do this It's still a headache , I haven't worked on it for hours , Now it looks better

So now, whenever there's a problem , I assume I'm at some point in the future Look at the current problems In the end, it's no better

In fact, the essence is to use the level change to transmit data , A high level means 1 Low level means 0

Suppose we have only one address line , A transmission can only be one level 0 or 1, Then you have to transmit a number 10( Binary system ) It has to be transmitted twice

This way of data transmission with only one address bus is called Serial transmission

Suppose we have two address buses , It can be transmitted once Two levels , Numbers 10 You just need to transmit it once

This uses multiple address buses , The way to transmit more than one signal at a time is Parallel transmission

When CPU When you need to read and write memory , First, the memory address is specified through the address bus , And then through the data bus to transmit data

So the number of elements of our address bus determines the addressing ability , When we have 32 When the root address bus is used, our addressing ability is 2^32=4G

32 position CPU and 64 position CPU The difference between

for instance : Use one 32 Bit CPU Sum two 64 Digit number

Usually 32 A wide CPU Most operations 32 Bit wide address bus and data bus

64 A wide CPU Most operations 64 Bit wide address bus and data bus

There is a problem ,64 Bits cannot be transferred to... At one time 32 Let's make CPU Calculate

According to the above transmission principle Must take 64 The digit number is split into two 32 Digital transmission

Through this example, we can see clearly that ,32 Bit CPU and 64 Bit CPU Different capabilities on the control bus

32 position CPU and 64 position CPU One of the differences is ,CPU The bit width determines the number of buses that can be controlled , The number of bus elements determines the addressing ability

32 The bus with bit maximum control is 32 root , The maximum addressing capability is 4G, The maximum number of bytes that can be transmitted at one time is 4byte

64 The bus with bit maximum control is 64 root , The maximum addressing capability is 256TB, The maximum number of bytes that can be transmitted at one time is 8byte

What can also be seen is ,32 Bit CPU Computing power can only be calculated 32 A data , Be able to 64 Bit data

This may not be easy to understand ,32 position CPU Only read at a time 32bit The data of , meanwhile 32 Bit CPU Only 32 Bit register

64 Bit has Backwards compatible characteristic ,64 You can run 32 Bit software , Can be done 32 The calculation of bits

Speaking of this , Think back to the question the interviewer asked , And my niece's puzzle As clear as a mirror

64 What are the advantages of ?

Now let's talk about 64 What's the advantage of bit

our CPU The steps to execute the procedure are :

  1. CPU Read PC The instruction that the pointer points to , abbreviation Fingering (fetch)
  2. CPU analysis Instruction register The instructions in , Determine the type and parameters of the instruction , abbreviation decode (decode)
  3. If it's a compute type instruction , Then it's up to the logic unit to calculate ; If it's a storage type instruction , So it's executed by the control unit , abbreviation perform (execute)
  4. Return the execution result to the register or store the register data in memory , abbreviation Storage (store)
  5. PC The pointer increases by itself , And ready to get the next instruction

The above step is a loop, also known as CPU Instruction cycle ,CPU It's a cycle after cycle , Go round and begin again .

 Instruction cycle
Instruction cycle

stay CPU In the running cycle, you can see , There's a core component register

It uses Program register Instruction register , The essence of registers is The pointer , The pointer is the address , An address is a string of numbers

And that's the size of the string , The size of the address is determined by Addressing capability decision , Addressing capability is Bus Root number of

The number of bus elements is determined by CPU Number of digits Decisive

Speaking of this, we should have understood 64 position CPU The advantages of , Uncle long, let's make a conclusion

64 position CPU It can be executed Bigger The operation of numbers , How big is it ? 2^64 So big

This advantage is not obvious in general applications , But for the numerical calculation more application is very obvious

64 position CPU It can address more memory space

If 32 position /64 I'm talking about procedures , So the instructions are 64 A still 32 Bit

32 Bit instruction in 64 Execute on a bit machine , It's not difficult , Compatible . If it is 64 Bit instruction , stay 32 It's hard to execute on a bit machine

32 Bit instruction in 64 When a bit machine is running , What's needed is a set of compatibility mechanisms, just OK 了 , however 64 Bit instruction in 32 Execute on a bit machine ,32 No bit register can store the parameters of the instruction .

The operating system is also a program , If it is 64 Bit operating system , In other words, the instructions of the program in the operating system are 64 Bit instruction , So it can't be installed in 32 On the bit machine .

Supplementary content

I mentioned registers earlier , Many people are very unfamiliar with registers , Here is a detailed explanation

CPU Internal structure diagram
CPU Internal structure diagram

It is obvious from the above figure that , Inside the dotted line , The register is CPU Internally integrated , Memory is external

When we access memory, we need to use register To find the corresponding address , Then execute the corresponding instructions

here CPU Data will be generated on the bus Read or write in Memory clock signal , Finally, the contents of memory will be CPU The contents of registers are updated or read in

What is a register , It's already said , A register is a pointer , There's an address in it

That's all for this issue , I'm uncle long , See you next time

Finally, I really need to share with you 、 forward 、 give the thumbs-up , These are the driving forces of my creation , Thank you for your

版权声明
本文为[Dragon jump 12]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201207085101172a.html