Are mutexes really slower?

前端 未结 5 2075
梦毁少年i
梦毁少年i 2020-12-24 07:38

I have read so many times, here and everywhere on the net, that mutexes are slower than critical section/semaphores/insert-your-preferred-synchronisation-method-here. but i

5条回答
  •  不知归路
    2020-12-24 08:20

    In the book "Multithreading application in win32" by Jim Beveridge and Robert Wiener it says: "It takes almost 100 times longer to lock an unowned mutex than it does to lock an unowned critical section because the critical section can be done in user mode without involving the kernel"

    And on msdn here it says "critical section objects provide a slightly faster, more efficient mechanism for mutual-exclusion synchronization"

提交回复
热议问题