Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Sep 2016 13:46:15 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Question about wmb() and rmb() and task switching
Message-ID:  <b1c776bb-e332-1af9-809b-1f9e96e76eb8@selasky.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?b1c776bb-e332-1af9-809b-1f9e96e76eb8>