-1

Given two threads a and b that read from a shared queue. If a modifies the queue and adds an element to it does it mean that when b comes along it will do a cache miss because the queue has been modified?

As in, will altering something at the end of a queue(guessing it'd a mem block) cause cache lines to be INVALID and force them to re-read?

Thanks in advance.

  • 1
    What do you mean by a `shared queue`? Are you using some kind of Java blocking queue? It feels like your question is not Java-related, and much more low-level, since you talk about invalid cache lines and cache misses. – mjuarez May 09 '20 at 19:14
  • I think the JLS introduced the "happen-before" occurrences to make it clearer on what happens in case of cache misses, but I can't tell much more... – Matthieu May 09 '20 at 21:33

1 Answers1

0

False sharing occurs when two threads operate on two different variables that share the same cache line.

Whether false sharing occurs in your queue therefore highly depends on the specific implementation.

mpoeter
  • 2,574
  • 1
  • 5
  • 12