linux thread synchronization

后端 未结 5 949
北海茫月
北海茫月 2021-02-06 14:52

I am new to linux and linux threads. I have spent some time googling to try to understand the differences between all the functions available for thread synchronization. I sti

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-06 15:28

    A note on futexes - they are more descriptively called fast userspace mutexes. With a futex, the kernel is involved only when arbitration is required, which is what provides the speed up and savings.

    Implementing a futex can be extremely tricky (PDF), debugging them can lead to madness. Unless you really, really, really need the speed, its usually best to use the pthread mutex implementation.

    Synchronization is never exactly easy, but trying to implement your own in userspace makes it inordinately difficult.

提交回复
热议问题