处理器、操作系统:32 位、64 位 [英] Processor, OS : 32bit, 64 bit

查看:37
本文介绍了处理器、操作系统:32 位、64 位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手,来自非 CS 背景(没有正式学位).我主要使用 C# 编写 winform.

I am new to programming and come from a non-CS background (no formal degree). I mostly program winforms using C#.

我对 32 位和 64 位感到困惑....我的意思是,听说过 32 位操作系统、32 位处理器以及基于它们的程序可以拥有最大内存.它如何影响程序的速度.还有很多问题一直在脑海中浮现.

我试图阅读一些计算机组织和体系结构的书籍.但是,要么是我太笨,看不懂里面写了什么,要么作者假设读者有一些 CS 背景.

I tried to go through some Computer Organization and Architecture books. But, either I am too dumb to understand what is written in there or the writers assume that the reader has some CS background.

谁能用通俗易懂的英语向我解释这些事情,或者向我指出可以做到这一点的事情.

我读过类似在 32 位模式下,他们可以访问高达 4GB 内存;在 64 位模式下,他们可以访问更多....我想知道为什么要这样做.

I have read things like In 32-bit mode, they can access up to 4GB memory; in 64-bit mode, they can access much much more....I want to know WHY to all such things.

BOUNTY:下面的答案非常好......尤其是 Martin 的一个.但是,我正在看一个详尽的解释,但用的是简单的英语.

BOUNTY: Answers below are really good....esp one by Martin. But, I am looking at a thorough explanation, but in plain simple English.

推荐答案

这一切都归结为电线.

在数字电路中,只有 0 和 1(通常是低电压和高电压)可以从一个元件(CPU)传输到另一个元件(存储芯片).如果我只有 1 条线,我只能在每个时钟周期通过线发送 1 或 0.这意味着我只能寻址 2 个字节(假设字节寻址,并且为了速度,整个地址仅在 1 个周期内传输!).

In digital circuits, only 0's and 1's (usually low voltage and high voltage) can be transmitted from one element (CPU) to another element (memory chip). If I have only 1 wire, I can only send either a 1 or a 0 over the wire per clock cycle. This means I can only address 2 bytes (assuming byte addressing, and that entire addresses are transmitted in just 1 cycle for speed!).

如果我有 2 条线,我可以寻址 4 个字节.因为我可以通过两条线发送:(0, 0), (0, 1), (1, 0), or (1, 1).所以基本上它是电线数的 2 次方.

If I have 2 wires, I can address 4 bytes. Because I can send: (0, 0), (0, 1), (1, 0), or (1, 1) over the two wires. So basically it's 2 to the power of # of wires.

所以如果我有 32 条线,我可以寻址 4 GB,如果我有 64 条线,我可以寻址更多.

So if I have 32 wires, I can address 4 GB, and if I have 64 wires, I can address a lot more.

工程师可以使用其他技巧来寻址比线路允许的更大的地址空间.例如.将地址分成两部分,在第一个周期发送一半,在下一个周期发送后一半.但这意味着您的内存接口速度将减半.

There are other tricks that engineers can do to address a larger address space than the wires allow for. E.g. splitting up the address into two parts and sending one half in the first cycle and the second half on the next cycle. But that means that your memory interface will be half as fast.

将我的评论编辑到这里(未编辑);) 如果有人还有任何有趣的内容要添加,请将其设为 wiki.

Edited my comments into here (unedited) ;) And making it a wiki if anyone has anything interesting to add as well.

就像其他评论提到的那样,2^32(2 的 32 次方)= 4294967296,即 4 GB.2^64 是 18,446,744,073,709,551,616.为了进一步深入(您可能在 Hennesey & Patterson 中读到过这个),处理器包含用作暂存空间"来存储其计算结果的寄存器.CPU 只知道如何进行简单的算术运算并知道如何移动数据.自然地,这些寄存器的大小与架构的#-bits"宽度相同,因此 32 位 CPU 的寄存器将是 32 位宽,而 64 位 CPU 的寄存器将是 64 位宽的.

Like other comments have mentioned, 2^32 (2 to the power of 32) = 4294967296, which is 4 GB. And 2^64 is 18,446,744,073,709,551,616. To dig in further (and you probably read this in Hennesey & Patterson) processors contains registers that it uses as "scratch space" for storing the results of its computations. A CPU only knows how to do simple arithmetic and knows how to move data around. Naturally, the size of these registers are the same width in bits as the "#-bits" of architecture it is, so a 32-bit CPU's registers will be 32-bits wide, and 64-bit CPU's registers will be 64-bits wide.

当涉及到浮点(处理双精度)或其他 SIMD 指令(单指令、多数据命令)时,会有例外.CPU 向主存储器(RAM)加载和保存数据.由于 CPU 也使用这些寄存器来计算内存地址(物理和虚拟),因此它可以寻址的内存量也与其寄存器的宽度相同.有一些 CPU 使用特殊的扩展寄存器处理地址计算,但在工程师意识到他们需要它之后添加的那些我称之为经过思考".

There will be exceptions to this when it comes to floating point (to handle double precision) or other SIMD instructions (single-instruction, multiple data commands). The CPU loads and saves the data to and from the main memory (the RAM). Since the CPU also uses these registers to compute memory addresses (physical and virtual), the amount of memory that it can address is also the same as the width of its registers. There are some CPUs that handles address computation with special extended registers, but those I would call "after thoughts" added after engineers realize they needed it.

目前 64 位用于寻址实际物理内存相当多.由于实用性,大多数 64 位 CPU 在将 CPU 连接到内存时会省略相当多的电线.使用宝贵的主板空间来运行始终为 0 的电线是没有意义的.更不用说为了在今天的 DIMM 密度下获得最大数量的 RAM 需要 40 亿个 DIMM 插槽 :)

At the moment 64-bits is quite a lot for addressing real physical memory. Most 64-bit CPUs will omit quite a few wires when it comes to wiring up the CPU to the memory due to practicality. It won't make sense to use up precious motherboard real estate to run wires that will always have 0's. Not to mention in order to have the max amount of RAM with today's DIMM density would require 4 billion dimm slots :)

除了增加的内存量之外,64 位处理器为大于 2^32 的整数提供更快的计算.以前的程序员(或编译器,也由程序员编写;)必须通过占用两个 32 位寄存器并处理任何溢出情况来模拟具有 64 位寄存器.但在 64 位 CPU 上,它将由 CPU 本身处理.

Other than the increased amount of memory, 64-bit processors offer faster computation for integer numbers larger than 2^32. Previously programmers (or compilers, which is also programmed by programmers ;) would have to simulate having a 64-bit register by taking up two 32-bit registers and handling any overflow situations. But on 64-bit CPUs it would be handled by the CPU itself.

缺点是 64 位 CPU(一切都相同)会比 32 位 CPU 消耗更多的功率,因为​​(大约)所需的电路数量是其两倍.然而,在现实中,你永远不会得到平等的比较,因为新的 CPU 将采用新的硅工艺制造,具有更少的功率泄漏,允许您在相同的芯片尺寸中塞入更多的电路等.但是 64 位架构将消耗两倍记忆.与使用固定指令长度的架构相比,曾经被认为丑陋"的 x86 可变指令长度实际上是一个优势.

The drawback is that a 64-bit CPU (with everything equal) would consume more power than a 32-bit CPU just due to (roughly) twice the amount of circuitry needed. However, in reality you will never get equal comparison because newer CPUs will be manufactured in newer silicon processes that have less power leakage, allow you to cram more circuit in the same die size, etc. But 64-bit architectures would consume twice as much memory. What was once considered "ugly" of x86's variable instruction length is actually an advantage now compared to architectures that uses a fixed instruction size.

这篇关于处理器、操作系统:32 位、64 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆