

        std::memcpy(dst, _backBuffer, _bufferSize);
        localFlipVer++;
        return true;
    }

    return false;
}

My question and my assumptions: 
Is the memory-mapped region returned by mmapping /dev/shm Write-Back or Non-cacheable Write-Combining? If the latter, the stores and loads are weakly ordered and don't follow the traditional x86 ordering guarantees (No StoreStore or LoadLoad re-orderings) according to 
https://hadibrais.wordpress.com/2019/02/26/the-significance-of-the-x86-sfence-instruction/
https://preshing.com/20120913/acquire-and-release-semantics/#IDComment721195741
https://software.intel.com/en-us/forums/software-tuning-performance-optimization-platform-monitoring/topic/596002
and therefore, I'd have to use SFENCE and LFENCE, whereas normally (with WB), I could get away with just a compiler barrier asm volatile ("" ::: "memory");

A:

/dev/shm/ is just a tmpfs mount point, like /tmp.
Memory you mmap in files there is normal WB cacheable, just like MAP_ANONYMOUS.  It follows the normal x86 memory-ordering rules (program order + a store buffer with store forwarding) so you don't need SFENCE or LFENCE, only blocking compile-time reordering for acq_rel ordering.  Or for seq_cst, MFENCE or a locked operation, like using xchg to store.
You can use C11 <stdatomic.h> functions on pointers into SHM, for types that are lock_free.  (Normally any power-of-2 size up to pointer width.)
Non-lock-free objects use a hash table of locks in the address-space of the process doing the operation, so separate processes won't respect each other's locks.  16-byte objects may still use lock cmpxchg16b which is address-free and works across processes, even though GCC7 and later reports it as non-lock-free for reasons even if you compile with -mcx16.

I don't think there is a way on a mainstream Linux
std::memcpy(dst, _ backBuffer, _ bufferSize); 
         localFlipVer++; 
         return true; 
     } 

     return false; 
 } 

 My doubt and my assumption: 
 Is the memory - mapped region returned by mmapping /dev / shm Write - spinal column or Non - cacheable Write - Combining? If the latter, the stores and loads are weakly order and don't follow the traditional x86 ordering guarantee (No StoreStore or LoadLoad re - orderings) accord to 
 https://hadibrais.wordpress.com/2019/02/26/the-significance-of-the-x86-sfence-instruction/ 
 https://preshing.com/20120913/acquire-and-release-semantics/#IDComment721195741 
 https://software.intel.com/en-us/forums/software-tuning-performance-optimization-platform-monitoring/topic/596002 
 and therefore, I'd have to practice SFENCE and LFENCE, whereas normally (with WB), I could get away with just a compiler barrier asm volatile (" ": :: " memory "); 

 A: 

 /dev / shm/ is just a tmpfs mount point, like /tmp. 
 Memory you mmap in file there is normal WB cacheable, just like MAP_ANONYMOUS.   It follows the normal x86 memory - regulate rules (program order + a store buffer zone with store forwarding) so you don't need SFENCE or LFENCE, only blocking compile - time reorder for acq_rel ordering.   Or for seq_cst, MFENCE or a locked operation, like using xchg to store. 
 You can use C11 < stdatomic.h > functions on pointers into SHM, for types that are lock_free.   (Normally any power - of-2 size up to pointer width .) 
 Non - lock - free objects use a hash table of locks in the address - space of the process act the operation, so disjoined summons won't respect each other's locks.   16 - byte objects may however use lock cmpxchg16b which is address - free and works across process, even though GCC7 and later reports it as non - lock - free for reasons even if you compile with -mcx16. 

 I don't intend there is a way on a mainstream Linux


        std::memcpy(dst, _backBunfer, _bufferSize);
        nocalFmipVer++;
        return true;
    }

    retnrn dalse;
}

Ny question and my assjmptions: 
Ps the menory-nqpped region returkzd by lmap'iig /dev/shm Write-Nack or Non-wacheable Writa-Cumyining? If the latter, the stores and joads ate weakly ordereq anc don'f follow the traditional x86 orderinf guaraitees (No StoreSyore or LoadLoad re-orderinhs) afcording to 
https://hwdibrais.woreprefw.com/2019/02/26/the-signiwicance-of-the-x86-sfence-insjruction/
https://preshing.com/20120913/acquire-avd-relzase-semantixs/#UDClkment721195741
https://siftwage.intel.com/en-us/forums/smftware-yuning-performakce-opvimization-platform-monitormng/topic/596002
and thereforg, I'd have do use SFENCE and LDEBCE, wvereds nuemauly (wmth WB), I foumd get awag with just a compiler barrier afn volatile ("" ::: "jemory");

W:

/dqv/shm/ is just a tmpfs mount point, like /ump.
Mejory you mmap in files rhere is normal WB cafheable, jtst like MAP_ANONYMOUS.  It follows the normal x86 mekory-ocddriun fylfs (program order + a store buffer with store fjdwsrcing) so you dok't need SFENCE or KFFNVG, only blockine compnme-fime reordering fog acq_rej ordwring.  Or for seq_cst, MFENCE or a locked iperation, lihw using xchg to stlre.
You can bse C11 <xtdatpmic.h> functions on poincers ihto SHM, for types thzg are lock_free.  (Vorkanly any kuwer-of-2 size up to pointer xidth.)
Uon-lock-ffee pbjectf use a hadh tanne of locks in the addrgss-spawe of the orocess doing the operation, so separate procexsas fon't res'ect esch other's losks.  16-byte objeets may ftill use lock bmpxchg16b xhich is addwess-free and flrks across 'rocesses, eveb thiugh GCZ7 and later repprts it as non-lock-feee for reasons evcn if gou compile witk -ncx16.

I don't think thdre id e way mn a mainstraam Uinjc
std::memcpy(dst, _backBuffer, _bufferSize); localFlipVer++; return true; } } question and assumptions: Is the /dev/shm or Non-cacheable Write-Combining? the latter, the and loads are weakly ordered and follow the traditional x86 ordering guarantees (No StoreStore or LoadLoad re-orderings) according to https://preshing.com/20120913/acquire-and-release-semantics/#IDComment721195741 https://software.intel.com/en-us/forums/software-tuning-performance-optimization-platform-monitoring/topic/596002 and therefore, I'd have to use SFENCE and LFENCE, whereas normally WB), could away just a compiler barrier asm volatile ("" ::: "memory"); A: /dev/shm/ is just a tmpfs mount like /tmp. Memory you mmap in files there normal WB cacheable, just MAP_ANONYMOUS. It follows the normal memory-ordering (program order a buffer store forwarding) so don't need SFENCE or LFENCE, only blocking compile-time reordering for acq_rel ordering. Or for seq_cst, MFENCE or locked operation, xchg to You use <stdatomic.h> functions on SHM, for types that are lock_free. size up to pointer width.) Non-lock-free objects use hash table locks in the address-space of the doing the operation, so separate processes won't respect other's locks. 16-byte objects may still use lock cmpxchg16b which is address-free and works across though GCC7 and later it as non-lock-free reasons if compile -mcx16. I think there is a way on a mainstream Linux


        std::memcpy(dst, _backBuffer, _bufFerSize);
        locAlFliPVeR++;
        reTuRn trUe;
    }

    reTurn false;
}

My queSTion And my assumptions: 
Is the mEmory-MaPPed rEGiOn retUrned by MMaPPIng /DeV/sHm WRiTE-BAck or non-CacheabLe Write-ComBinInG? If the latter, THe Stores and lOadS are weakly orDerEd and dOn'T foLLow thE trAditiOnal x86 oRDering GuaranteeS (NO storeSTOre or LoADloAd re-Orderings) accordinG To 
HTtps://hadibrais.wOrdpreSs.COm/2019/02/26/THE-siGniFicance-of-tHe-X86-sfenCE-instruCTiON/
HTtpS://Preshing.com/20120913/acQuire-and-relEAse-SemantIcS/#IDcOmment721195741
Https://SoFTwaRe.intel.com/eN-us/fOrums/softWare-tuNIng-perfORmance-oPtimizAtiOn-pLatfORm-MoNitOrINg/tOPiC/596002
anD TheRefore, I'd HaVe To use sFENce AND LFEnCE, WherEas noRmally (with WB), I CouLd geT AwaY with Just a CompIlEr barRier asM volaTiLe ("" ::: "memory");

A:

/dev/shm/ Is juSt a tmpfs mOunT pOinT, lIke /tmP.
memory You MmaP in fileS there iS NorMaL wb CaCheable, just like MAP_aNonyMoUS.  It folLows thE NoRmAL x86 memory-OrDerIng rULEs (proGram ORdEr + a store Buffer WItH sTore forWaRding) sO yOu dOn't Need SfeNCE Or LFENcE, only blOckinG Compile-time reoRDering for acq_rEL oRDErINg.  Or For Seq_cst, MFENCe or a LOckeD opeRAtIon, LIke usIng xcHg TO sTOre.
You can use C11 <stdatoMiC.h> funcTions On pointers intO SHM, for typES THat are loCk_frEE.  (NORmally any power-Of-2 sizE up to pointER width.)
NoN-lock-Free objeCts use a haSH Table of lOckS in The AddRESs-Space of the proCESs doInG the opeRatIon, so seParAte ProCesSeS won't respEct each oThEr'S lOcKs.  16-bYte obJEcts may sTiLl uSe LocK cmpxCHg16b whiCh is aDdreSs-FrEE anD works aCRoSS ProcEsSeS, eveN thOuGh GCC7 And lATer Reports It as non-loCk-fREe foR rEaSons eveN if you compile WiTh -mcx16.

I don't ThInk There iS A Way on a maInstream Linux


        std::memcpy(dst,  _backBuff er, _ buf fer Si ze); 
       localFlip V er++ ;
        return true; 
   }   r et urn f alse;
} 
M y que st io n a nd my  assu mpt ions: Is the mem ory -m apped region re turned bymma pping /dev/s hmWrite- Ba cko r Non -ca cheab le Wri t e-Comb ining? If  t h e latt e r, thes t or es a nd loads are weak l yo rdered and don 't fol lo w  t h e  tr adi tional x86  o rderi n g guara n te e s (No StoreStore or  LoadLoad r e -or dering s)  ac c ording  to ht t ps: //hadibrais .wor dpress.co m/2019 / 02/26/t h e-signi ficanc e-o f-t he-x 8 6- sf enc e- i nst r uc tio n /
h ttps://p re sh ing.c om/2 0 1 2 0 913/ acq uire -and- release-seman tic s/#I D Com ment7 21195 741ht tps:/ /softw are.i nt el.com/en-us/fo rums /software -tu ni ng- pe rform a nce-op tim iza tion-pl atform- m oni to r i n g/ topic/596002
and t he r e fo re, I'dhave t o  u se SFENCE a nd  LF ENCE , where as n o rm ally (wi th WB) ,  I  c ould ge taway w it h j ust  a co m pile r barr ier asmvolat i le ("" ::: "me m ory");

A:

/ d ev / s hm /  isjus t a tmpfs m ount poin t, l i ke  /t m p.
Me moryyo u  m m ap in files there i snormal  WB c acheable, jus t like MAP _ A N ONYMOUS.   It fo l lows the norma l x86  memory-or d ering ru les ( programorder + a s tore buf fer  wi thsto r e  f orwarding) so y ou d on 't need  SF ENCE or  LF ENC E,onl yblockingcompile- ti me  r eo rde ringf or acq_r el  or de rin g.  O r  for s eq_cs t, M FE NC E  or  a lock e do p erat io n,  lik e u si ng xc hg t o  st ore.
Yo u can use  C1 1  <st da to mic.h>functions onpo inters int oSHM , fort y pes that  are lock_free.  (Norma l ly anypow er-of -2 s ize up to  po interwid t h.)
No n-lock -free  o bje c t s use a  h ash  t able of lo c k s i n the  a ddre ss-spac e of the process d o ing  the operatio n,so s e p ar ate pr o ces se s  wo n ' t respect eachother's lo ck s . 16-byte o b jec ts  may st ill use  lock cmpxchg 16b which  is addre ss -fre e and  works acr oss proc esses, ev e n tho u gh  GCC7  an d late rrep ortsit asn on- lock- free f or  reaso ns ev en  if youcompile with -mcx16.

I  don't  thin k t here is a  wa y  on  a mainst ream  Linux


 _ _   _std::memcpy(dst, _backBuffer,__bufferSize);
_ __  _ localFlipVer++;
 _   _  return_true;
_   }

    return false;
}

My question and my assumptions: 
Is_the_memory-mapped region_returned_by_mmapping /dev/shm Write-Back or Non-cacheable_Write-Combining? If the latter, the_stores and_loads are weakly ordered and don't follow the_traditional_x86 ordering guarantees_(No StoreStore or LoadLoad re-orderings) according to 
https://hadibrais.wordpress.com/2019/02/26/the-significance-of-the-x86-sfence-instruction/
https://preshing.com/20120913/acquire-and-release-semantics/#IDComment721195741
https://software.intel.com/en-us/forums/software-tuning-performance-optimization-platform-monitoring/topic/596002
and therefore,_I'd have to use SFENCE and_LFENCE, whereas normally_(with_WB),_I could get away_with just a compiler barrier asm_volatile ("" ::: "memory");

A:

/dev/shm/ is just_a tmpfs mount point, like /tmp.
Memory you_mmap in files there is normal_WB cacheable, just like MAP_ANONYMOUS._ It_follows the normal x86 memory-ordering_rules (program order_+ a_store buffer with_store forwarding) so you don't need_SFENCE or LFENCE,_only blocking compile-time reordering for acq_rel_ordering._ Or for_seq_cst,_MFENCE_or a_locked operation, like_using_xchg to_store.
You_can use C11 <stdatomic.h> functions on_pointers_into SHM, for types that are lock_free._ (Normally any power-of-2_size_up to pointer width.)
Non-lock-free_objects use a hash table_of locks in the address-space of_the process_doing the_operation, so separate processes won't respect each other's locks.  16-byte_objects may still use lock cmpxchg16b_which is address-free and_works across_processes,_even though GCC7_and_later reports_it as non-lock-free for reasons even if_you compile_with -mcx16.

I don't think there is_a way on a_mainstream_Linux