What is the consensus number for semaphores?

前端 未结 4 1584
灰色年华
灰色年华 2021-02-02 17:36

(I think that) the consensus number for a mutex is 2.

What is the consensus number for semaphores (like in pthread_sem_*)?

What is the consensus number for condi

4条回答
  •  轮回少年
    2021-02-02 18:01

    Infinite, surely? But they're not wait free.

    Perhaps I'm misunderstanding. You say a mutex has a consensus number of 2 - what's your source for that? It's designed to allow any number of threads to share a resource, with the trade-off of blocking.

    Atomic test-and-set has a consensus number of 2, but doesn't block.


    To clarify: semaphores, mutexes, etc. are primitives that you can simply wrap around a shared resource to make it safe (as long as you do it correctly). They may block, but they will guarantee your data is safe.

    The paper you cite is about the primitives needed to protect data without blocking, which is hard. The same primitives may be useful for locks as well, but that's just a nice extra.

提交回复
热议问题