views:

246

answers:

2

I have some questions on Cache synchronization operations.

Invalidate - before cpu tries to read a portion of memory updated by a device, the corresponding memory needs to be invalidated.

Flush - Before the device read a portion of memory updated by CPU, CPU must flush(write back is also correct? ) the contents from cache to memory.

Please confirm whether my above understanding is correct?

when you want to combine both flush and invalidate? I heard that while playing with device control descriptors we need to synchronize by combining flush and invalidate. Why so?

Do we need to follow a sequence like flush followed by invalidate?

Is there a scenario in which invalidate followed by flush will be useful?

In short , I want to understand the combination of flush and invalidate.

Thx!

+1  A: 

Flush does write back the contents of cache to main memory, and invalidate does mark cache lines as invalid so that future reads go to main memory.

I think you would combine flush and invalidate if the device was updating a block of memory: the flush would ensure that the device had the latest contents, and the invalidate would then ensure that when the device had finished that the CPU would read the new contents from memory.

BruceCran