互斥体真的慢吗? [英] Are mutexes really slower?

查看:61
本文介绍了互斥体真的慢吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络上的任何地方读了很多遍,互斥锁比关键部分/信号灯/在此处插入您首选的同步方法要慢.但我从未见过任何论文或研究或任何支持该主张的东西.

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 have never seen any paper or study or whatever to back up this claim.

那么,这个想法从何而来?这是神话还是现实?互斥体真的慢吗?

so, where does this idea come from ? is it a myth or a reality ? are mutexes really slower ?

推荐答案

在吉姆·贝弗里奇(Jim Beveridge)和罗伯特·维纳(Robert Wiener)所著的《 win32中的多线程应用程序》一书中,它说:锁定一个无主的互斥锁所花的时间几乎是它的100倍锁定无主的关键部分,因为关键部分可以在用户模式下完成而无需涉及内核"

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"

在msdn 此处上说关键部分对象为互斥同步提供了一种更快,更有效的机制"

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

这篇关于互斥体真的慢吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆