当前位置:网站首页>Pipeline details of IPC (interprocess communication)
Pipeline details of IPC (interprocess communication)
2022-06-29 10:00:00 【qqq2018】
linux and windows There are
Pipes and shared memory ( One of the fastest IPC) difference :
1. Pipeline one communication and four data copies : By user space buf Copy data to the kernel -> The kernel copies the data into memory -> Memory to kernel -> Kernel to user space buf. Shared memory copies data only twice : User space to memory -> Memory to user space .
2. Pipelines are implemented with circular queues , Continuous data transmission can be unlimited . The data size of shared memory is fixed each time ;
3. Shared memory can be accessed randomly , Pipes can only be read and written sequentially ;
Anonymous pipeline
Communicating between processes with a common ancestor . signal communication Follow the process and die , So it is Only in memory Temporary files for . Because of this file No file name , Cannot be opened by a non parent process , It can only be used for communication between kinship processes , Therefore, the communication pipeline formed by files without names is called “ Anonymous pipeline ”.
principle : Creating a child process copies some resources of the parent process, including files . If the parent process creates a file before creating the child process , Then the descriptor of this file will be shared by the child processes created later , Father 、 Child processes can communicate through this file . If both sides of the communication can only read , The other side can only write , Then this file is a pipeline that can only send messages in one direction .
Realization : A process calls a function pipe() Create a pipe .pipe() The function is to create a memory file , But unlike the functions that create ordinary files , function pipe() Two file descriptors of this file will be returned for the process . among , A read-only file descriptor , A file descriptor that writes only attributes , That is, the process passes fildes[0] You can only read files , And by fildes[1] You can only write files . After determining the transmission direction , Closed by one party fildes[0], Closed by one party (close()) File descriptor fildes[1], Thus, the connection of the pipeline becomes a one-way transmission pipeline in the following cases .

The parent process creates a pipeline

After the parent process creates the child process , Pipes are also shared

The communicating party turns off reading , One side closes the write . Method :close() File descriptor
limitations : Built in memory , So its capacity can't be very large ; A stream of unformatted bytes is transmitted , It is required that both parties using the pipeline must agree on the data format to be transmitted .
name pipes
On the actual file system Real documents , So it can communicate between any process .
Because the named pipeline strictly follows the principle of first in first out to transmit data , So this kind of pipe is also called FIFO file .
The synchronization between communication processes needs to be ensured by the pipeline itself , Named pipes are also a can only One way access The file of .
principle : in other words , Named pipes provide a pathname to associate with , With FIFO The file form of exists in the file system , Generate a physical file in the file system , Other processes only need to access the file path , Can communicate with each other through pipelines . Open the pipeline file in read-only mode on the read data side , Open the pipeline file in write only mode on the write data side .
Difference from ordinary files :
Ordinary files cannot realize byte stream management , Multi process access resource conflict ;
FIFO Files are managed by byte stream , Follow the first in, first out principle , Does not involve shared resource access .
The operation flow is :mkfifo -> open -> read(write) -> close ->unlink.
边栏推荐
- Fully Automated Delineation of Gross Tumor Volume for Head and Neck Cancer on PET-CT Using Deep Lear
- 数据源连接池未关闭的问题 Could not open JDBC Connection for transaction
- 2020-09-17 gateway业务流程 两个任务:referer认证和非商品模板化
- Caused by: org.apache.xerces.impl.io.MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8
- A 3D Dual Path U-Net of Cancer Segmentation Based on MRI
- 在Activity外使用startActivity()方法报错原因与解决办法
- Do you know what BFD is? This article explains the principle and usage scenarios of BFD protocol in detail
- 367. 有效的完全平方数-二分法
- Mysql5.7 installation tutorial in centos7 under Linux
- Causes and solutions of error reporting by using startactivity() method outside the activity
猜你喜欢

Gross Tumor Volume Segmentation for Head and Neck Cancer Radiotherapy using Deep Dense Multi-modalit

A 2.5D Cancer Segmentation for MRI Images Based on U-Net

Middle order traversal of Li Kou 94 binary tree

Deep Learning-based Automated Delineation of Head and Neck Malignant Lesions from PET Images

Application of decorator mode, packaging ServletRequest and adding addparameter method

Automatic 3D Detection and Segmentation of Head and Neck Cancer from MRI Data.

A method of creating easy to manage and maintain thread by C language

Segmentation of Head and Neck Tumours Using Modified U-net

完美二叉树、完全二叉树、完满二叉树

Flutter 基础组件之 ListView
随机推荐
Leetcode MySQL database topic 178
你必须知道的23个最有用的Elasticseaerch检索技巧
Fully Automated Gross Tumor Volume Delineation From PET in Head and Neck Cancer Using Deep Learning
微信小程序实现store功能
监控数据源连接池使用情况
2020-09-29 非商品模板化代码层次 rapidjson库
数据库常见面试题(附答案)
RecyclerView刷新闪烁与删除Item时崩溃问题
A method of creating easy to manage and maintain thread by C language
Implementation of multi key state machine based on STM32 standard library
C语言中通过sprintf()函数构造sql语句
Automatic Multi-Organ SegmVentation on Abdominal CT With Dense V-Networks
Set up lamp environment under cenos7
JVM之 MinorGC、 MajorGC、 FullGC、
聊聊你理解的线程与并发
Invalidconnectionattributeexception exception exception handling
Leetcode skimming -- teponacci sequence
In XML layout, the button is always displayed on the top layer
User level threads and kernel level threads
Slider validation code