Saurabh
Saurabh

Reputation: 1069

Is L1 cache flushed when a process jumps core?

A program should always read back what it wrote earlier even with most relaxed consistency. Say a program was running on core1 and is moved another core2 between write and subsequent read, what are the responsibilities of OS, and memory subsystems to make sure read returns the previously written?

Upvotes: 0

Views: 179

Answers (1)

Margaret Bloom
Margaret Bloom

Reputation: 44066

The OS must ensure that all the CPU state that is program visible is correctly saved and restored upon a context switch.

So in theory L1 must be flushed.
In practice however this depends on the platform, for example the x86 architecture enforce cache coherency with the MESI and as such every CPU share a coherent image of the memory in their caches and the L1 cache is not flushed.
However other types of cache must be flushed, for example the TLBs.

Upvotes: 2

Related Questions