本文介绍了需求分页:计算有效的内存访问时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白这个问题的答案:

I can't understand the answer to this question:

考虑使用具有TLB寄存器的一级分页的OS.如果页面错误率是10%,并且在需要时应重新加载脏页面,请在以下情况下计算有效访问时间:

Consider an OS using one level of paging with TLB registers. If the page fault rate is 10% and dirty pages should be reloaded when needed, calculate the effective access time if:

  • TLB查找= 20 ns
  • TLB命中率= 80%
  • 内存访问时间= 75 ns
  • 交换页面时间= 500,000 ns
  • 50%的页面脏了.

答案:

T = 0.8(TLB + MEM)+ 0.2 ( 0.9 [TLB + MEM + MEM] + 0.1 [TLB + MEM + 0.5(磁盘)+ 0.5(2Disk + MEM)] ) = 15,110 ns

T = 0.8(TLB+MEM) + 0.2(0.9[TLB+MEM+MEM] + 0.1[TLB+MEM + 0.5(Disk) + 0.5(2Disk+MEM)]) = 15,110 ns

你能解释为什么吗?

推荐答案

在本文中,有效"时间表示预期"或平均"时间.因此,您需要花费一些时间来访问个别情况下的页面,并将每种情况与其概率相乘.通过分成多个级别的案例,表达有些复杂.情况是:

In this context "effective" time means "expected" or "average" time. So you take the times it takes to access the page in the individual cases and multiply each with it's probability. The expression is somewhat complicated by splitting to cases at several levels. The cases are:

    物理地址
  • 80%的时间在TLB缓存中.这使我们有80%的时间可以访问TLB寄存器,还可以访问页面本身:0.8(TLB + MEM)
  • 剩余20%的时间不在TLB缓存中.这会分成更多的情况,因此它为我们提供了0.2(loooong expression)(该表达式实际上没有该括号,但我将其作为一个错字,因为没有它,系数的总和不会为1,并且它不会知道他们是否愿意).情况是:
      页面仍然被映射的
    • 有20%的时间有90%,但是地址从高速缓存中掉了,所以我们必须从页面映射中读取更多的内存.因此,对TLB寄存器的访问加上对页表的访问加上对页面本身的访问的90%次:0.9(TLB + MEM + MEM).提到了一级分页,因此这里只是1个额外的内存访问,但是实际的实现通常具有两级分页,因此会有2个额外的内存访问.
    • 10%(在这20%中;此表达式表明了这一点,但问题尚不明确,建议整体上为10%)需要从磁盘加载页面的次数.这给TLB寄存器(失败)访问和对页表(失败)访问提供了10%的访问时间的10倍,是加载页面所需的访问时间的10倍.要加载它,必须为其腾出空间,因此它必须放下另一页.这分为两个选项:
      • 要删除的页面有50%是干净的,因此系统只需要读取新内容:0.5(Disk).
      • 要删除的页面有50%是脏的,因此系统需要将其写入磁盘(MEM+Disk)并读入新内容(Disk),从而提供0.5(2Disk + MEM)
      • 80% of time the physical address is in the TLB cache. That gives us 80% times access to TLB register plus access to the page itself: 0.8(TLB + MEM)
      • remaining 20% of time it is not in TLB cache. That splits into further cases, so it gives us 0.2(loooong expression) (the expression doesn't actually have that parenthesis, but I'll take it as a typo, because the coefficients don't add up to 1 without it and it makes no sense if they don't). The cases are:
        • 90% (of those 20%) of times the page is still mapped, but the address fell out of the cache, so we have to do extra memory read from the page map. So 90% times access to TLB register plus access to the page table plus access to the page itself: 0.9(TLB + MEM + MEM). One-level paging is mentioned, so it's just 1 extra memory access here, but practical implementations generally have two-level paging and would thus have 2 extra memory accesses.
        • 10% (of those 20%; the expression suggests this, but the question is not clear and suggests rather that it's 10% overall) of times the page needs to be loaded from disk. This gives 10% times the (failed) access to TLB register and (failed) access to page table and than it needs to load the page. To load it, it will have to make room for it, so it will have to drop another page. This splits to two options:
          • 50% the page to be dropped is clean, so the system just needs to read the new content: 0.5(Disk).
          • 50% the page to be dropped is dirty, so the system needs to write it to disk (MEM+Disk) and read in the new content (Disk), giving the 0.5(2Disk + MEM)

          我认为在后两种(交换)情况下应该包括一些额外的内存访问,因为需要两次访问以将上一页标记为不可用,而新页在页表中标记为可用.

          I think some extra memory accesses should be included in the last two (swap) cases as two accesses are needed to mark the previous page unavailable and the new page available in the page table.

          这也是非常不切实际的,因为在实际系统中,当需要一个用于阅读页面的空间时,系统总是选择一个干净的页面来替换.为了确保页面整洁,有一个后台进程遍历脏页并将其写出.它占用了一些计算资源,因此实际上应该算作一次内存访问,但是要少得多,因为页面错误不需要等待写入完成.

          It is also highly unrealistic, because in real system when a room for reading in a page is needed, the system always chooses a clean page to replace. To make sure it has clean pages there is a background process that goes over dirty pages and writes them out. It takes some computing resources, so it should actually count toward memory access a bit, but much less since the page faults don't need to wait for the writes to finish.

          该表达式实际上是错误的.应该是

          The expression is actually wrong. It should be either

          如果页面错误是TLB未命中率的10%或

          if page faults are 10% of TLB misses or

          如果页面错误占所有访问的10%.您对此并不明确,但是如果公式中不包含0.2 * 0.9,则我认为后者是后者.

          if page-faults are 10% of all accesses. You are not explicit about it, but I would assume the later if the formula didn't include that 0.2*0.9, which suggests the former.

          这篇关于需求分页:计算有效的内存访问时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 20:37