当前位置:网站首页>多进程编程(五):信号量
多进程编程(五):信号量
2022-07-02 23:05:00 【HDD615】
参考链接:信号量
进程间通信方式的区别
1、首先最简单的就是管道,管道又分为匿名管道和有名管道
匿名管道只能用于具有亲属关系的进程间通信,单向传输;如果想要双向通信,就要设置两个管道;匿 名管道是一种特殊的文件,存在内核中的缓冲区,传输数据是无格式的字节流数据,大小受限制。
而有名管道,通过在文件系统中创建文件的方式,解决了匿名管道只能用于具有亲属关系的进程通信的 问题,从而无关系的进程也可以进行通信。
2、消息队列,实际上是内核中的一个消息链表,它克服了管道通信数据是无格式的字节流的问题。但是消息队列的通信速度不及时,因为每次数据的写入和读取都要经过用户态和内核态的拷贝
3、共享内存,通过直接在内存中分配一个共享内存空间,解决了数据拷贝的问题,多个进程都可以通过地址来直接访问这块共享的内存空间,但是多个进程同时竞争可能会出现数据的错乱
共享内存是最高效的一种方式
4、信号量,是一种进程同步的一种手段,可以用来保护共享资源,确保任一时刻只有一个进程在访问共享资源。
通常用来和共享内存一块使用,也就是在获得锁之后,再对共享内存进行操作(写/读)
边栏推荐
- 直击产业落地!飞桨重磅推出业界首个模型选型工具
- [shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)
- JS interviewer wants to know how much you understand call, apply, bind no regrets series
- 130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
- 95页智慧教育解决方案2022
- Digital twin visualization solution digital twin visualization 3D platform
- 35页危化品安全管理平台解决方案2022版
- MySQL advanced learning notes (4)
- Understanding and application of least square method
- yolov5test. Py comment
猜你喜欢
Custom throttling function six steps to deal with complex requirements
Seckill system design
[shutter] open the third-party shutter project
Many to one, one to many processing
Shell脚本基本使用
67页新型智慧城市整体规划建设方案(附下载)
The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
接口差异测试——Diffy工具
MySQL advanced learning notes (III)
[target detection] r-cnn, fast r-cnn, fast r-cnn learning
随机推荐
QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)
Thinkadmin V6 arbitrary file read vulnerability (cve-2020-25540)
Interpretation of new plug-ins | how to enhance authentication capability with forward auth
What website can you find English literature on?
CADD课程学习(4)-- 获取没有晶体结构的蛋白(SWISS-Model)
Judge whether the binary tree is full binary tree
Installing redis under Linux
What is the standard format of a 2000-3000 word essay for college students' classroom homework?
Chapter 4 of getting started with MySQL: data types stored in data tables
Is the multitasking loss in pytoch added up or backward separately?
Digital twin visualization solution digital twin visualization 3D platform
【单片机项目实训】八路抢答器
请问大家在什么网站上能查到英文文献?
Architecture: database architecture design
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
Question e: merged fruit -noip2004tgt2
Andorid 获取系统标题栏高度
35页危化品安全管理平台解决方案2022版
ArrayList分析2 :Itr、ListIterator以及SubList中的坑
Practical series - free commercial video material library