系统V和Posix信号量之间的差异 [英] Differences between System V and Posix semaphores

查看:261
本文介绍了系统V和Posix信号量之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System V和Posix信号量之间的折衷是什么?

What are the trade-offs between using a System V and a Posix semaphore?

推荐答案

http://www.linuxdevcenter.com/pub/a/linux/2007/05/24/semaphores-in-linux.html?page=4rel =nofollow noreferrer> O'Reilly :

From O'Reilly:



  • System V和POSIX信号量之间的一个明显区别
    实现是在系统V
    可以控制多少信号量
    的计数可以增加或减少;
    ,而在POSIX中,信号量计数
    增加并减少1。

  • POSIX信号量不允许操作信号量权限,
    ,信号量允许

    信号量的权限更改为原始
    权限的子集。

  • 信号量的初始化和创建是原子的

  • 从用法的角度看,System V信号量是笨拙的,而POSIX
    信号量是直接的

  • POSIX信号量(使用未命名的信号量)的可扩展性比系统V信号量多
    。在
    用户/客户端场景中,每个用户
    创建自己的服务器实例
    ,最好使用POSIX
    信号量。

  • 系统V信号量在创建信号量对象时创建一个
    信号量数组,而POSIX信号量
    只创建一个。因为这个
    功能,与POSIX
    信号量相比,系统
    V中的信号量创建(内存
    占用空间)是昂贵的。

  • 已经说POSIX信号量的性能优于
    基于系统V的信号量。

  • POSIX信号量为进程范围的信号量提供了一种机制,而不是
    全系统信号量。所以,如果一个
    开发人员忘记关闭
    信号量,在进程退出
    信号量被清理。在简单的
    术语中,POSIX信号量为非持久的
    信号量提供
    机制。

  • One marked difference between the System V and POSIX semaphore implementations is that in System V you can control how much the semaphore count can be increased or decreased; whereas in POSIX, the semaphore count is increased and decreased by 1.
  • POSIX semaphores do not allow manipulation of semaphore permissions, whereas System V semaphores allow you to change the permissions of semaphores to a subset of the original permission.
  • Initialization and creation of semaphores is atomic (from the user's perspective) in POSIX semaphores.
  • From a usage perspective, System V semaphores are clumsy, while POSIX semaphores are straight-forward
  • The scalability of POSIX semaphores (using unnamed semaphores) is much higher than System V semaphores. In a user/client scenario, where each user creates her own instances of a server, it would be better to use POSIX semaphores.
  • System V semaphores, when creating a semaphore object, creates an array of semaphores whereas POSIX semaphores create just one. Because of this feature, semaphore creation (memory footprint-wise) is costlier in System V semaphores when compared to POSIX semaphores.
  • It has been said that POSIX semaphore performance is better than System V-based semaphores.
  • POSIX semaphores provide a mechanism for process-wide semaphores rather than system-wide semaphores. So, if a developer forgets to close the semaphore, on process exit the semaphore is cleaned up. In simple terms, POSIX semaphores provide a mechanism for non-persistent semaphores.

这篇关于系统V和Posix信号量之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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