高速缓存未命中,TLB未命中和页面错误 [英] cache miss, a TLB miss and page fault

查看:864
本文介绍了高速缓存未命中,TLB未命中和页面错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以清楚地解释我缓存未命中,tlb未命中和页面错误之间的区别吗,它们如何影响有效的内存访问时间?

Can someone clearly explain me the difference between a cache miss, a tlb miss and page fault, and how do these affect the effective memory access time?

推荐答案

让我逐步解释所有这些事情.

Let me explain all these things step by step.

CPU生成逻辑地址,其中包含page numberpage offset.

The CPU generates the logical address, which contains the page number and the page offset.

page number用于索引到page table,以获得相应的page frame number,一旦我们有了physical memory的页面框架(也称为主内存),就可以应用获得正确的记忆力.

The page number is used to index into the page table, to get the corresponding page frame number, and once we have the page frame of the physical memory(also called main memory), we can apply the page offset to get the right word of memory.

为什么要使用TLB(翻译后备缓冲区)

问题是页面表存储在physical memory中,有时可能很大,为了加快逻辑地址到物理地址的转换,有时我们使用TLB由昂贵且更快的关联内存组成,因此,我们不必先进入页表,而是进入TLB并使用page number索引到TLB中,并获得page frame number,如果找到它,我们将完全避免使用page table(因为我们同时具有page frame numberpage offset)并形成physical address.

The thing is that page table is stored in physical memory, and sometimes can be very large, so to speed up the translation of logical address to physical address , we sometimes use TLB, which is made of expensive and faster associative memory, So instead of going into page table first, we go into the TLB and use page number to index into the TLB, and get the corresponding page frame number and if it is found, we completely avoid page table( because we have both the page frame number and the page offset) and form the physical address.

TLB小姐

如果在TLB中找不到page frame number,则仅将其称为TLB miss,然后转到page table查找相应的page frame number.

If we don't find the page frame number inside the TLB, it is called a TLB miss only then we go to the page table to look for the corresponding page frame number.

TLB命中

如果我们在TLB中找到了page frame number,将其称为TLB hit,则无需转到页表.

If we find the page frame number in TLB, its called TLB hit, and we don't need to go to page table.

页面错误

当正在运行的程序访问的页面不存在于物理内存中时发生.这意味着该页面存在于辅助存储器中,但尚未加载到物理存储器的框架中.

Occurs when the page accessed by a running program is not present in physical memory. It means the page is present in the secondary memory but not yet loaded into a frame of physical memory.

缓存命中

缓存内存是一种小型内存,其运行速度比物理内存快,因此我们总是在进入物理内存之前先进入缓存.如果我们能够在高速缓存内部的高速缓存存储器中找到相应的单词,则将其称为cache hit,我们甚至不需要进入物理内存.

Cache Memory is a small memory that operates at a faster speed than physical memory and we always go to cache before we go to physical memory. If we are able to locate the corresponding word in cache memory inside the cache, its called cache hit and we don't even need to go to the physical memory.

缓存未命中

仅当映射到cache memory时无法找到缓存内的内存(称为cache miss)的相应block(类似于物理内存page frameblock)之后,我们转到physical memory,并执行通过page tableTLB的所有过程.

It is only after when mapping to cache memory is unable to find the corresponding block(block similar to physical memory page frame) of memory inside cache ( called cache miss ), then we go to physical memory and do all that process of going through page table or TLB.

所以流程基本上就是这个

So the flow is basically this

1 .首先转到cache memory,如果它是cache hit,那么我们就完成了.

1.First go to the cache memory and if its a cache hit, then we are done.

2 .如果它是cache miss,请转到步骤3.

2. If its a cache miss, go to step 3.

3 .首先转到TLB,如果它是TLB hit,则使用形成的physical address进入物理内存,我们完成了.

3. First go to TLB and if its a TLB hit, go to physical memory using physical address formed, we are done.

4 .如果它是TLB miss,则转到page table以获取用于形成physical address的页面的帧号.

4. If its a TLB miss, then go to page table to get the frame number of your page for forming the physical address.

5 .如果找不到page,则为page fault.如果所有帧都被某个页面占用,请使用page replacement algorithms之一,否则只需将所需页面从secondary memory加载到physical memory帧即可.

5. If the page is not found, its a page fault.Use one of the page replacement algorithms if all the frames are occupied by some page else just load the required page from secondary memory to physical memory frame.

尾注

我所讨论的流程与虚拟缓存(进程之间更快但不可共享)有关,在物理缓存的情况下,该流程肯定会发生变化(虽然较慢,但可以在进程之间共享).缓存可以通过多种方式解决.如果您愿意深入学习,请查看.

The flow I have discussed is related to virtual cache(faster but not sharable between processes), the flow would definitely change in case of physical cache(slower but can be shared between processes). Cache can be addressed in multiple ways. If you are willing to dive deeply have a look at this and this.

这篇关于高速缓存未命中,TLB未命中和页面错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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