Question about wmb() and rmb() and task switching

From: Hans Petter Selasky <hps_at_selasky.org>
Date: Fri, 23 Sep 2016 13:46:15 +0200
Hi,

Does use of wmb() and rmb() for amd64 as defined in 
sys/amd64/include/atomic.h required use of critical_enter()/critical_exit().

I was looking at the code in sys/amd64/amd64/cpu_switch.S which switches 
between threads and I don't see any "sfence" instructions in there.

Given the following piece of dummy code:

var_a = 1;
var_b = 2;
wmb();

If there is a task switch between writing var_a and var_b so that the 
thread in question continues executing on another core, can it happen 
that the write to var_a is not flushed when wmb() is executed?

var_a = 1;
<task switch to different CPU core>
var_b = 2;
wmb();

--HPS
Received on Fri Sep 23 2016 - 09:41:29 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:08 UTC