Chinaunix首页 | 论坛 | 博客
  • 博客访问: 376882
  • 博文数量: 38
  • 博客积分: 3071
  • 博客等级: 中校
  • 技术积分: 423
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-15 11:11
文章分类

全部博文(38)

文章存档

2017年(1)

2011年(1)

2010年(5)

2009年(6)

2008年(3)

2007年(22)

我的朋友

分类:

2007-03-29 09:34:45

1.Cache的两个类型
    --Write Through
    当写数据进Cache时,也同时更新了相应的Memory里的内容
    --Write back
    只是写到Cache里,Memory的内容要等到cache保存的要被别的数据替换或者系统做cache flush时,才会被更新。

2.Cache的两个函数
    --Flush
    把Cache内容写回Memory,当Cache为Write through,不需要Flush
    --Invalidate
    把Cache内容直接丢掉不要。

3.Cache的使用场合
    当有DMA在使用memory的时候,一般要用到cache的处理。因为DMA在访问memory时是不经过cache的。比较典型的比如在Ethernet,wireless,USB等driver里,DMA会操作descriptors和packet buffers,Driver要做这些处理
    --如果driver使用descripter和packet buffer的地址都是cache的地址,那么
    a).Driver在读descripter里一些状态比如Owned by CPU/DMA,有没有收到包时,要对descripter当前结构里的内容做cache invalidate,收到packet后,也要对packet buffer做cache invalidate
    b).Driver在写descripter里一些状态比如Owned by DMA,要发送包时,要对descripter当前结构里的内容做cache flush,发送packet时,也要对packet buffer做cache flush
    --有些driver会对descripter使用uncache 地址,那么上面两种情况里invalidate/flush就不用做了。一般很少会对packet buffer也用uncache地址的,因为对packet内容的处理将会很频繁,使用uncache会很慢。而descripter一般由于结构比较小,如果也使用cache地址的话,做invalidate/flush的时间消耗可能会比uncache的还要多。

阅读(2324) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~