内存单位,计算大小,帮助!
我正在准备计算机科学课上的测验,但我不确定如何找到正确的答案。问题有 4 种,例如——
假设以下系统: 包含 4 GB 的辅助存储器, 相当于 4 KB 的内存块, 字大小相当于 4 个字节。
- 一个块有多少个单词, 表示为 2^_? (写下 指数)
- 需要多少位数 代表一个单词的地址 这个系统的辅助存储器?
- 需要多少位数 表示a中一个字节的地址 这个系统的块?
- 如果一个文件包含32兆字节,如何 许多块包含在 文件,表示为 2^_?
有什么想法如何找到解决方案吗?老师没有给我们任何解决方案的例子,所以我无法弄清楚如何通过向后工作或任何其他方式来做到这一点,而且我在网上也没有找到任何好的资源。
有什么想法吗?
I am preparing for a quiz in my computer science class, but I am not sure how to find the correct answers. The questions come in 4 varieties, such as--
Assume the following system:
Auxiliary memory containing 4 gigabytes,
Memory block equivalent to 4 kilobytes,
Word size equivalent to 4 bytes.
- How many words are in a block,
expressed as 2^_? (write the
exponent) - What is the number of bits needed to
represent the address of a word in
the auxiliary memory of this system? - What is the number of bits needed to
represent the address of a byte in a
block of this system? - If a file contains 32 megabytes, how
many blocks are contained in the
file, expressed as 2^_?
Any ideas how to find the solutions? The teacher hasn't given us any examples with solutions so I haven't been able to figure out how to do this by working backwards or anything and I haven't found any good resources online.
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
诸如此类的问题基本上可以归结为使用指数并了解不同部分如何组合在一起。例如,根据您的示例问题,我们会这样做:
从您的描述中我们知道一个字是 4 字节(2^2 字节),一个块是 4 KB(2^12 字节)。要找到一个块中的单词数,我们只需将块的大小除以单词的大小 (2^12 / 2^2),这告诉我们每个块有 2^10 个单词。
这类问题本质上是前一问题的延伸。首先,您需要找到内存中包含的单词数。由此您可以获得在内存中表示一个字所需的位数。所以我们被告知内存包含 4 GB(2^32 字节)并且单词为 4 字节(2^2 字节);因此内存中的单词数为 2^32/2^2 = 2^30 个单词。由此我们可以推断,在内存中表示一个单词需要 30 位,因为每个位可以表示两个位置,而我们需要 2^30 个位置。
由于这被标记为家庭作业,我将剩下的问题作为练习:)
Questions like these basically boil down to working with exponents and knowing how the different pieces fit together. For example, from your sample questions, we would do:
From your description we know that a word is 4 bytes (2^2 bytes) and that a block is 4 kilobytes (2^12 bytes). To find the number of words in one block we simply divide the size of a block by the size of a word (2^12 / 2^2) which tells us that there are 2^10 words per block.
This type of question is essentially an extension of the previous one. First you need to find the number of words contained in the memory. And from that you can get the number of bits required to represent a word in the memory. So we are told that memory contains 4 gigabytes (2^32 bytes) and that the word is 4 bytes (2^2 bytes); therefore the number words in memory is 2^32/2^2 = 2^30 words. From this we can deduce that 30 bits are required to represent a word in memory because each bit can represent two locations and we need 2^30 locations.
Since this is tagged as homework I will leave the remaining questions as exercises :)
向后工作。这实际上是非常简单的数学。 (忽略“辅助”一词。)
Work backwards. This is actually pretty simple mathematics. (Ignore the word "auxilliary".)