ChinaUnix.net
相关文章推荐:

semaphore mutex 区别

http://kb.vigal.net/semaphore-mutex-relatio/ Home About Wizard Ray « 在复杂逻辑中尽量使用短小的方 法 FCKEditor 在ASP.NET下的部署笔记 » semaphoremutex的关系 2009/07/13, 13:03 在多线程编程中,经常使用到如semaphoremutex等许多线程间同步用的工具,但是mutexsemaphore区别一直让 人困惑在Pintos Project的实践中,逐渐摸索到一些其中的区别。以下的实现来...

by hdc1112_cu - Linux文档专区 - 2010-02-21 16:41:38 阅读(2613) 回复(0)

相关讨论

Difference between mutex and semaphore Source: http://koti.mbnet.fi/niclasw/mutexsemaphore.html 先看看网上著名的厕所理论的描述: mutex: Is a key to a toilet. One person can have the key - occupy the toilet - at the time. When finished, the person gives (frees) the key to the next person in the queue. Officially: "mutexes are typically used to serialise access to a section of re-entrant code that...

by jerrykinki - Linux文档专区 - 2009-02-19 17:06:21 阅读(872) 回复(0)

想了一下,没有办法呢

by 太平绅士 - C/C++ - 2015-03-19 23:15:09 阅读(7806) 回复(16)

semaphore通过设置计数器,可以实现多个进程间的同步。 event的话,可以设置event标志,当某个标志出现时,等待此标志的线程就可以运行。 那么这两者之间有什么区别

by 使者0123 - Linux环境编程 - 2012-12-03 20:54:57 阅读(1123) 回复(2)

看起来好象是不一样的,sys/sem.h里申明的是XSI的semaphore, 而semaphore.h里的函数我查了man文档里似乎是有关realtime的,是不是这样呢?请指教?

by jiangqihua - C/C++ - 2014-01-07 10:46:50 阅读(5443) 回复(2)

只记得好像32 64 上有区别

by dutysmart - C/C++ - 2013-05-21 11:52:03 阅读(1301) 回复(3)

感觉completion和locked mutex差不多。在之前的版本中,因为up和down没有用spin lock保护。所以semaphore和completion在smp下存在区别。但是在2.6.27中,两者都使用了spin lock保护。那么现在他们还有区别吗?看了下2.6.27的实现,complete会唤醒所有的等待进程,而up只会唤醒一个等待进程。不知道这个是不是它们的区别?其他还有什么不同吗? 谢谢指点。

by xiegang112 - 内核源码 - 2009-05-31 12:32:37 阅读(4114) 回复(1)

semaphore在kernel,用户进程和pthread中都用到,这几个semaphore有什么区别吗? [ 本帖最后由 ljshan 于 2009-1-21 16:11 编辑 ]

by ljshan - Linux环境编程 - 2009-01-21 16:08:37 阅读(1222) 回复(0)

本帖最后由 okocha-jay 于 2010-06-10 11:00 编辑 大家都知道,volatile修饰的共享变量,是因为它可能被“意外”的改变,比如说在当前执行线程之外被修改; 所以强迫编译器每次都去读内存; 另外,共享变量也可以用mutex来保证线程间互斥访问; mutex保护的变量没必要volatile。 问题: 什么情形下修饰共享变量用volatile, 什么情形用mutex保护? 谢谢

by okocha-jay - C/C++ - 2010-06-13 02:49:20 阅读(8025) 回复(20)

semaphores Remember file locking ? Well, semaphores can be thought of as really generic advisory locking mechanisms. You can use them to control access to files, shared memory , and, well, just about anything you want. The basic functionality of a semaphore is that you can either set it, check it, or wait until it clears then set it ("test-n-set"). No matter how complex the stuff that follo...

by 我爱spring - Linux文档专区 - 2007-06-27 20:42:12 阅读(500) 回复(0)

mutex可以在smp上实现互斥吗?谢

by bluempire - 内核源码 - 2013-05-16 10:31:32 阅读(1178) 回复(1)