manish bhardwaj
manish bhardwaj

Reputation: 11

Who place the data onto the cache?

Like we have locality of reference on which basis this data is copied to cache but who is responsible for this.

Is there any h/w or is there any s/f which perform this action?

Upvotes: 0

Views: 45

Answers (1)

Margaret Bloom
Margaret Bloom

Reputation: 44066

The CPU reads/writes data into the cache when an instruction that access the memory is executed.
So it's an on-demand service, data is moved upon a request.
It then try to keep the data in the cache as long as possible until there is no more space and a replacement policy is used to evict a line in favor of new data.
The minimal unit of data transferred is called line and it is usually bigger than the register size (to improve locality).

Some CPUs have a prefetcher that, upon recognition of specific memory access patterns, try to automatically move data into the cache before it is actually requested by the program.

Some architecture have instructions that performs as hints for the CPU to prefetch data from a specific address.
This let the software have a minimal control over the prefetching circuitry, however if the software wants to just move data into the cache it only has to read the data (the CPU will cache it, if caching is enabled in that region).

Upvotes: 2

Related Questions