named and unnamed posix semaphores

大憨熊 提交于 2019-12-05 11:22:33

If the two processes are unrelated you should use a named semaphore. If the two process are related (i.e. forked) or if you are just using the semaphore between threads you should use unnamed.

The advantages of unnamed are that you don't have to keep track of the names and any permissions nor unlink them. And unnamed semaphores can be use as a simple global variable (or on the heap) in the case where they are being shared between threads of the same process, or put in shared memory which will be inherited by the children in the case of a forked process.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!