为什么使用字节可寻址的内存而不是4字节可寻址的内存? [英] Why byte-addressable memory and not 4-byte-addressable memory?

查看:177
本文介绍了为什么使用字节可寻址的内存而不是4字节可寻址的内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么计算机具有字节可寻址内存,而没有4字节可寻址内存(或64位8字节可寻址内存)?是的,我看到有时候它会很有用,看起来太过优雅和过分了.优势是实质性的,还是真的是因为遗产?

Why do computers have byte-addressable memory, and not 4-byte-addressable memory (or 8-byte-addressable memory for 64bit)? Yeah, I see how it could be useful sometimes, it just seems inelegant and excessive. Are the advantages substantial, or is it really just because of legacy?

推荐答案

处理器实际上确实以64位的数量访问内存(自Pentium以来,x86就是这样做的); 64位处理器通常具有128位总线.此外,在访问主内存时,突发会填满整个缓存行,这甚至是更大的内存单元.

Processors actually do access memory in quantities of 64-bit (x86 did since Pentium or so); 64-bit processors often have a 128-bit bus. Plus, in accessing main memory, you have bursts that fill an entire cache line, which is even larger units of memory.

只有基于字节的寻址;这样只会增加很少的开销,而且一点也不多余.

It's only the addressing that is byte-based; this adds little overhead and is not excessive at all.

今天,对于网络协议,您绝对需要基于字节的寻址.使用基于字的寻址来实现TCP将会很困难:如果在17个字节的位置收到了什么,您想让read()返回什么?同样,更高的层是基于字节的:如果您以4个字节为单位显示"GET/HTTP/1.0"之类的请求行,则HTTP很难实现.本质上,您必须使用移位操作等将这些单词重新分成字节(由于基于字节的寻址,现在处理器可以在硬件中完成此操作).

Today, you absolutely need byte-based addressing for networking protocols. Implementing TCP with word-based addressing would be difficult: what do you want read() to return if what you received where 17 bytes? Likewise, higher layers are byte-based: HTTP would be fairly difficult to implement if you get a request line like "GET / HTTP/1.0" be presented in units of four bytes. You essentially would have to split the words back into bytes with shift operations and such (which now the processors do in hardware, thanks to byte-based addressing).

这篇关于为什么使用字节可寻址的内存而不是4字节可寻址的内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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