Linux线程互斥量--进程共享属性
来源:互联网 发布:js id select 不可用 编辑:程序博客网 时间:2024/05/19 23:28
多线程中,在互斥量和 读写锁的 属性中,都有一个叫 进程共享属性 。
对于互斥量,查询和设置这个属性的方法为:
pthread_mutexattr_getpshared
pthread_mutexattr_setpshared
我一开始不理解什么是 进程共享属性。 看了man中的说明如下
The pthread_mutexattr_getpshared() function shall obtain the value of the process-shared attribute from the attributes object referenced by attr. The pthread_mutexattr_setpshared() function shall set the process-shared attribute in an initialized attributes object referenced by attr.
The process-shared attribute is set to PTHREAD_PROCESS_SHARED to permit a mutex to be operated upon by any thread that has access to the memory where the mutex is allocated, even if the mutex is allocated in memory that is shared by multiple processes. If the process-shared attribute is PTHREAD_PROCESS_PRIVATE, the mutex shall only be operated upon by threads created within the same process as the thread that initialized the mutex; if threads of differing processes attempt to operate on such a mutex, the behavior is undefined. The default value of the attribute shall be PTHREAD_PROCESS_PRIVATE.
意思是:
这个属性有两个值
PTHREAD_PROCESS_SHARED
PTHREAD_PROCESS_PRIVATE, 顾名思义,是进程共享,和进程不共享。 也即是 当你的进程初始化一个互斥量后, 是只有自己的进程 可以使用,还是 其他进程也可以使用这个互斥量。
默认情况是 PTHREAD_PROCESS_PRIVATE, 只有本进程可以 对这个互斥量加锁等操作。
这时,别的进程,对私有的 互斥量 操作的行为,没有定义。
- Linux线程互斥量--进程共享属性
- linux线程属性、共享属性
- linux线程是否共享进程所有空间
- 求教:Linux下的线程是否与进程共享Uids
- Linux——进程与线程内存共享
- linux线程共享和进程内存的关系
- 进程,线程与信息共享
- Linux 互斥量Mutex 进程间共享
- Linux进程共享
- linux 线程 线程属性
- 将Win32 C/C++应用程序迁移到Linux-进程、线程和共享内存
- 将Win32 C/C++应用程序迁移到Linux-进程、线程和共享内存
- 【linux进程/线程】僵尸进程
- Linux 进程PK线程;互斥量PK信号量
- linux进程属性
- linux进程属性
- 【Linux基础】进程属性
- linux 进程间共享内存
- VS2010中字符集选择问题
- css3处理sprite背景图压缩来解决H5网页在手机浏览器下图标模糊的问题
- wampserver安装完以后碰到的问题
- 输油管道
- android 多点触摸图片缩放的具体实现方法
- Linux线程互斥量--进程共享属性
- STL迭代器失效
- the best opportunity to buy chinese film faced plywood
- LeakCanary: 让内存泄露无所遁形
- const和define的区别
- The type initializer threw an exception.
- Android基于多触控的图片缩放和拖动代码实现
- Ubuntu vim+ ctags(包含系统函数) + taglist 配置
- 小细节汇总