北去踏歌行 2018-02-13 07:35 采纳率: 0%
浏览 1306
已结题

Windows内核驱动如何让高速缓存(Cache)失效

Windows内核驱动如何让高速缓存(Cache)失效,
做视频采集卡,采集的视频总是有雪花点,发现DMA传输完成后,驱动取到的数据是不正确的,怀疑是内存与高速缓存(Cache)不一致引起的

使用AllocateCommonBuffer分配内存,看API说明在WIN7及之前版本,CacheEnabled参数是被忽略的,求教各位大神如何在DMA操作完成时,进行刷新。

 CacheEnabled

Specifies whether the allocated memory can be cached.

**This parameter is ignored. **The operating system determines whether to enable cached memory in the common buffer that is to be allocated. That decision is based on the processor architecture and device bus.

On computers with x86-based, x64-based, and Itanium-based processors, cached memory is enabled. It is assumed that all DMA operations performed by a device are coherent with the relevant CPU caches, which might be caching that memory. If your driver needs to disable caching, call AllocateCommonBufferEx instead.
  • 写回答

1条回答 默认 最新

  • qsmmmwpa 2018-02-13 09:45
    关注

    为了解决低速的外设和高速的CPU之间速度不匹配的问题。其中最主要是解决CPU和内存之间的速度匹配问题。
    内存太慢,不能及时提供数据给CPU用于计算(CPU现在几个GHZ的频率,速度比内存块很多),会大大降低CPU的效率,因此在CPU内核中集成了高速度的静态RAM,即SRAM构成的CACHE,提前用算法预读取内存中的数据到CACHE中去,CPU用到的大部分数据(96%以上)都直接在CACHE中得到,不用去读内存了,提高速度。
    缓存在其它地方也有用到,比如硬盘,但提到高速缓存一般是只的CPU内部的CACHE。

    评论

报告相同问题?