Ch6_Memory

Ch6 Memory

重點一

Pinciple of Locality

  • Pinciple of locality
    程式在任何時間點只會存取一小部分的位址空間,稱為區域性(Locality)
    • [1] temporal locality : 一個 item(instruction or data) 被存取到,很有可能會被再存取到。(e.g. loop)
    • [2] spatial locality : 一個 item 被存取到,它位址附近的 item 也很快會被存取到。(e.g. array,program)
  • Memory Technology
    • SRAM (static random access memory)
      • use for cache
      • static: content will last forever until lost power
      • low density, high power, fast
    • DRAM (dynamic random access memory)
      • use for main memory
      • dynamic: need to be fresh regularly
      • high density, low power, slow
    • Magnetic disk

重點二

Memory Hierarchy

image

  • at any given time, data is copied between only two adjacent levels
    • upper level: 離 Processor(CPU) 越近,記憶體越快 e.g. Cache
    • lower level: 離 Processor(CPU) 越遠,記憶體越慢 e.g. Disk
  • 目的 : 用便宜的技術擁有足夠的記憶體,並用最快的記憶體提供最快的存取速度
  • Block : the basic unit of information transfer
  • terminology (術語)
    • hit: data appears in upper level
      • hit rate: fraction of memory access found in the upper level
      • hit time: 判斷記憶體是否hit + 把上層資料搬到處理器的時間
    • miss: data needs to be retrived from a block in the lower level
      • miss rate: 1 - (hit rate)
      • miss penalty: Time to replace a block in the upper level(主要) + time to deliver the block to processor(CPU)裡的 cache (L1 Cache)
    • hit time << miss penalty

重點三

Cache

direct-mapped cache

image

  • 在 cache 裡要儲存 valid bit + tag + data
    • valid bit
      • 紀錄 cache 內是否為有效資訊
      • 1 = present, 0 = not present
      • initially 0,因為處理器剛啟動時,內容全部是無效的
        image
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值