From: chris.m.thomasson.1@gmail.com   
      
   On 12/6/2025 1:36 PM, Thomas Koenig wrote:   
   > Scott Lurndal schrieb:   
   >   
   >> Yes, you can add special instructions. However, the compilers will be   
   unlikely   
   >> to generate them, thus applications that desired the generation of such an   
   >> instruction would need to create a compiler extension (like gcc __builtin   
   functions)   
   >> or inline assembler which would then make the program that uses the   
   capability both compiler   
   >> specific _and_ hardware specific.   
   >>   
   >> Most extant SMP processors provide a compare and swap operation, which   
   >> are widely supported by the common compilers that support the C and C++   
   >> threading functionality.   
   >   
   > Interestingly, Linux restartable sequences allow for acquisition of   
   > a lock with no membarrier or atomic instruction on the fast path,   
   > at the cost of a syscall on the slow path (no free lunch...)   
   >   
   > But you also need assembler to do it.   
   >   
   > An example is, for example, at   
   > https://gitlab.ethz.ch/extra_projects/cpu-local-lock   
   >   
      
   I need to read more about them, but they kind of remind me of an   
   asymmetric mutex, or rwmutex. Ones that use a remote membar on the slow   
   path. Iirc, FlushProcessWriteBuffers on windows and iirc,   
   synchronize_rcu or membarrier on linux.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|