![]() |
![]() |
|
|||||||
| Register | Forum Rules | Getting Started! - Guide | Blog | Videos | Gallery | Members List | Social Groups | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Cache promble
Hi all,
I got a amazing problem of cache. In a driver, I allocate a block of memory using MmAllocateContiguousMemorySpecifyCache, and I set the cache type to MmNonCached. Then I map this memory into user mode using MmMapLockedPagesSpecifyCache where I also set the cache type to MmNonCached. So, here, both the driver and the application can access the shared memory. The problem comes up: assume pDriver is a system space virtual address and pApp is a user space virtual address and they both point to the same physical memory address. first, set a value in driver, *pDriver = 1; read the value in application and I get the value 1; second, set a value in driver *pDriver = 2; read the value in application but this time I still get the value 1; third, *pDriver = 3; read the value and get the value 2; and so on... So, from the 2nd time on, the driver set a new value but the application always get the previous value set by driver last time. Is it caused by cache? But I've already set the cache type as MmNonCached. Anyone can explain this problem? If the cache type is set to MmNonCached for MmMapLockedPagesSpecifyCache and MmAllocateContiguousMemorySpecifyCache, the memory will not be cached to any level of cache(both L1 and L2) or may be cached in a certain level of cache(L1 or L2? ) Anybody know this? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: Cache promble
Danial.F <DanialF@discussions.microsoft.com> writes:
> first, set a value in driver, *pDriver = 1; read the value in application > and I get the value 1; second, set a value in driver *pDriver = 2; read the > value in application but this time I still get the value 1; Did you inspect the machine instructions generated by the compiler, to verify that the driver actually writes the values to memory, and the application actually reads them from memory, instead of getting cached values from registers? If that is the problem, then declaring your pointers as pointing to volatile data should help. |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: Cache promble
From the asm instructions, i definitely see that the value is moved to memory
and the value is than moved from memory to a temp value for printing out to screen. The value is set in the driver and read in an application, they could be in different thread contexts. How can they get a different value? "Kalle Olavi Niemitalo" wrote: > Danial.F <DanialF@discussions.microsoft.com> writes: > > > first, set a value in driver, *pDriver = 1; read the value in application > > and I get the value 1; second, set a value in driver *pDriver = 2; read the > > value in application but this time I still get the value 1; > > Did you inspect the machine instructions generated by the > compiler, to verify that the driver actually writes the values to > memory, and the application actually reads them from memory, > instead of getting cached values from registers? If that is the > problem, then declaring your pointers as pointing to volatile > data should help. > |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
< Home - Windows Help - MS Office Help - Hardware Support >
| New To Site? | Need Help? |