Using Memory Fences ta head Produce Consumer Rtail R tail head Producer posting Item x: Consumer Load rtail,(tail) Load rhead,(head) Store(rtail,X spin Load Rtail(tail) Membarss if rhead==Rtail goto spin Rtail= rtail+1 Membarl Store(tail,rtail _oad R,(re head head=rhead+1 ensures that tail ptr ensures that r store(head), rhead is not updated before x has been stored not loaded befopEoceSS(R) x has been stored 2021/2/11 计算机体系结构Using Memory Fences 2021/2/11 计算机体系结构 20 Producer posting Item x: Load Rtail, (tail) Store (Rtail), x MembarSS Rtail=Rtail+1 Store (tail), Rtail Consumer: Load Rhead, (head) spin: Load Rtail, (tail) if Rhead==Rtail goto spin MembarLL Load R, (Rhead) Rhead=Rhead+1 Store (head), Rhead process(R) Producer Consumer tail head Rtail Rtail Rhead R ensures that tail ptr is not updated before x has been stored ensures that R is not loaded before x has been stored