Preemption is GC for memory reordering (2019)

(pvk.ca)

49 points | by mpweiher 4 days ago ago

8 comments

  • gblargg a day ago ago

    If I understand this correctly, it basically has the second thread wait until the first one experiences a hardware interrupt, which implicitly synchronizes memory. This avoids the first thread from needing any synchronization primitives that would slow it down.

    • j_seigh a day ago ago

      Sort of. Basically you have a situation where one thread needs to see another thread's memory accesses in sequential consistent order. If you can determine the other thread has synchronized its memory accesses at some point, then all its memory accesses before that are in observably sequentially consistent.

      The thing is you don't know exactly when that synchronization took place so your code logic has to take that into account. In the case of hazard pointers, false positives are ok and false negatives, i.e. thread is using reference that was not detected, cannot occur.

      There's 2 or 3 other tricks you can make hazard pointers wait-free. Getting rid of the conditional branching in the instruction pipeline gives you a considerable speed up.

  • Jweb_Guru a day ago ago

    Oh boy this is a cool blog post. Encourage everyone to read it.

    • senderista a day ago ago

      There are many more cool posts on that blog.

  • preetham_rangu a day ago ago

    same trick QSBR uses for lock-free reclamation, just framed at the OS scheduler level instead of userspace

  • 7e22v837278gb1p 2 days ago ago

    "GC"?

    • mwkaufma 2 days ago ago

      Garbage collection. It's in the leading paragraph of the article so I can see why it's easy to miss.

  • winterissnowing a day ago ago

    [flagged]