← Back to context

Comment by xmcqdpt2

9 hours ago

Does this avoid the dining philosopher deadlock?

yes, 'synchronize' uses a try_lock/backoff algorithm, same as std::scoped_lock.

edit: it could theoretically livelock, but I believe most if not all STM implementations also do not guarantee forward progress.

  • Purely optimistic STM implementations that abort transactions early and don't permit other transactions to read uncommitted data can guarantee forward progress, and I believe that both Haskell's STM and Fraser and Harris's STM do, though I could easily be mistaken about that.

    • Probably you are right. I vaguely remembered the "Why Transactional Memory Should Not Be Obstruction-Free" paper, but I might have misunderstood or forgotten what it meant (the implementation can be non obstruction-free, but it doesn't mean it can live-lock).

      1 reply →