缓存与分页 [英] caches vs paging

查看:165
本文介绍了缓存与分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在计算机体系结构课程中,我想很难区分缓存和页面.

So I'm in a computer architecture class, and I guess I'm having a hard time differentiating between caching and pages.

我能提出的唯一解释是,页面是操作系统在指定内存区域中欺骗程序的全部工作方式,而缓存是硬件在欺骗正在读取的操作系统的硬件方式从一个指定的内存区域开始,而实际上不是.

The only explanation I can come up with is that pages are the OS's way of tricking a program that it's doing all it's work in a specified region of memory, vs a cache memory is the hardware's way of tricking the OS that it's reading from one specified region of memory, when it's really not.

操作系统是否直接引导需要新页面"的硬件,还是操作系统试图读取当前高速缓存页面"超出范围"的地址所照顾的硬件(缺少地址?更好的条件.)

Does the os direct the hardware that it needs a "new page" or is that taken care of by the os trying to read the address that is "out of range" of the current cache "page" (for lack of a better term).

我是在正确的轨道上还是我完全疯了?

Am I on the right track or am I completely crazy?

推荐答案

缓存和页面是正交的概念.

Caching and pages are orthogonal concepts.

高速缓存是一种高速内存",用于最大程度地减少对大型低速内存"的访问次数.从最一般的意义上讲,高速内存"可能是您的硬盘,用于缓存从网络中获取的网页(低速内存").当然,在计算机体系结构的上下文中,术语缓存"更可能是指用于加速对较慢的RAM或磁盘的访问的物理RAM.

A cache is a high-speed "memory" that acts to minimise the number of accesses to a large low-speed "memory". In the most general sense, the high-speed "memory" could be your hard disk acting to cache web pages fetched from the web (low-speed "memory"). Of course, in the context of computer architecture, the term "cache" is more likely to refer to physical RAM used to speed up access to slower RAM or disk.

页面OTOH只是RAM或磁盘内容的管理单元.

Pages, OTOH, are simply a unit of management for the contents of RAM or disk.

这两个概念在实现虚拟内存系统时结合在一起.一个进程可以分配500 MB的内存.这可能比提供给进程的物理RAM还要多,所以操作系统在磁盘上分配了称为页的块,这些块将在进程的地址空间中保存某些逻辑页的内容.

These two concepts come together in implementing virtual memory systems. A process may allocate 500 MB of memory. This may be more that the physical RAM available to give to the process, so the operating system allocates blocks on disk called pages, which will hold the contents of certain logical pages in the process's address-space.

当进程访问其地址空间中的某个位置,并且当前未将关联页面映射到物理内存时,CPU会发出页面错误信号,并且操作系统会在进程进入过程中通过从磁盘获取页面进行响应暂停状态.页面映射完成后,该过程将恢复,并能够像一直访问该内存位置一样访问该内存位置.

When the process accesses a location in its address-space, and the associated page isn't currently mapped into physical memory, the CPU signals a page fault, and the OS responds by fetching the page from disk while the process is in a suspended state. Once the page is mapped, the process resumes and is able to access that memory location as if it was there all along.

普遍认为虚拟内存是一种诱使进程认为其具有大量RAM的方式,而不是对此进行思考的唯一方法.您还可以考虑将进程的地址空间逻辑上存储在磁盘页面上,而OS辅助映射到RAM只是一种缓存那些页面内容的方式,这样该进程就不会持续访问硬盘驱动器.从这个意义上说,缓存和分页虚拟内存在逻辑上是同一件事.请记住,虽然这种观点可能有助于理解这两个概念之间的关系,但它并不是完全准确的,因为有可能根本没有虚拟内存,而只有物理内存(实际上,大多数嵌入式系统都在运行).这样).

The common view that virtual memory is a way of tricking the process into thinking it has tons of RAM isn't the only way to think about this. You could also think of a process's address-space as being logically stored on disk pages, with the OS-assisted mapping into RAM being just a way to cache the contents of those pages such that the process isn't continually accessing the hard drive. In this sense, caching and paged virtual memory are logically the same thing. Just keep in mind that, while this viewpoint may help to understand the relationship between the two concepts, it isn't entirely accurate, since it is possible to run without virtual memory at all, just physical memory (in fact, most embedded systems run this way).

这篇关于缓存与分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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