Mutex VS Semaphore VS Spinlock
来源:互联网 发布:文笔最好的网络作家 编辑:程序博客网 时间:2024/04/28 10:55
本文转载至:https://freethreads.wordpress.com/2010/02/19/mutex-vs-semaphore-vs-spinlock/
Similarity
– All of these are used for synchronization
Difference
Mutex provides one person to access a single resource at a time, others must wait in a queue. Once this person is done, the guy next in the queue acquire the resource.
So access is serial, one guy after other. Too aggressive.
Semaphore are useful if multiple instances (N) of a resource is to be shared among a set of users. As soon as all N resources are acquired, any new requester has to wait. Since there is no single lock to hold, there is as such no ownership of a semaphore.
Spinlock is an aggressive mutex. In mutex, if you find that resource is locked by someone else, you (the thread/process) switch the context and start to wait (non-blocking).
Whereas spinlocks do not switch context and keep spinning. As soon as resource is free, they go and grab it. In this process of spinning, they consume many CPU cycles. Also, on a uni-processor machine they are useless and perform very badly (do I need to explain that?)
- Mutex VS Semaphore VS Spinlock
- pthread mutex vs spinlock
- spinlock vs. mutex
- Semaphore VS Mutex
- Mutex vs. Semaphore
- Pthreads mutex vs Pthreads spinlock
- Pthreads mutex vs Pthreads spinlock
- Pthreads mutex VS Pthreads spinlock
- Pthreads mutex vs Pthreads spinlock
- Pthreads mutex vs Pthreads spinlock
- Pthreads mutex VS Pthreads spinlock
- Pthreads mutex VS Pthreads spinlock
- spinlock mutex semaphore rwlock
- mutex, spinlock, semaphore
- spinlock, semaphore 和 mutex
- Mutex vs. Semaphore, what is the difference?
- 互斥锁(mutex) VS 信号量(semaphore)
- Mutex,spinlock,semaphore,临界区
- 创建Maven父子项目及发布到tomat的完整过程
- 薄弱环节——洗脑
- 使用maven 时 com.sun.image.codec.jpeg 找不到类
- http://sourceforge.net/p/keepass/wiki/Recover%20Windows%20User%20Account%20Credentials/
- tcpdump 移植
- Mutex VS Semaphore VS Spinlock
- java中的类加载机制
- 微软开源.NET Core的执行引擎CoreCLR
- mac上使用github命令提交代码实例(一)增加文件
- php:$_REQUEST、$_POST、$_GET的区别和联系
- Sizeof与Strlen的区别与联系
- Tomcat优化配置 相关(转http://ihuangweiwei.iteye.com/blog/1233941)
- 关于定义view
- vc USB的HID通讯类封装