当前位置:网站首页>[note] IPC traditional interprocess communication and binder interprocess communication principle
[note] IPC traditional interprocess communication and binder interprocess communication principle
2022-07-03 23:04:00 【Li Baoming】
Tradition IPC
Two copy process :
1. The message sender stores the message data to be sent into the memory buffer , Enter kernel state through system call .
2. Then kernel program allocates memory in kernel space , And open up a memory cache , call copy_from_user() Copy data from the user space memory cache to the kernel cache in kernel space .
3. When receiving data, the receiver process creates a memory buffer in its own user space .
4. Then the kernel program calls copy_to_user() Copy the data from the kernel cache to the memory cache of the receiver process .
This completes a data transmission between processes .
This traditional IPC There are two problems with communication :
1. Poor performance , A data transfer needs to go through : Memory cache --> Kernel cache --> Memory cache , need 2 Secondary data copy ;
2. The buffer for receiving data is provided by the data receiving process , But the receiving process doesn't know how much space is needed to store the data to be transferred , So we can only open up as much memory space as possible or call first API Receive the message header to get the small of the message body , These two methods are either a waste of space or a waste of time .
Binder IPC
Binder IPC The memory mapping involved in the mechanism is through mmap() To achieve .
mmap(): Is a memory mapping method in the operating system .
Memory mapping is simply to map a block of memory area of user space to kernel space . After the mapping relationship is established , The user's modification of this memory area can directly reflect the kernel space ; On the other hand, the kernel space modification of this area can also directly reflect the user space .
Memory mapping can reduce the number of data copies , Achieve efficient interaction between user space and kernel space .
The changes of the two spaces can be directly reflected in the mapped memory area , So as to be perceived by each other's space in time
Once complete Binder IPC The communication process is usually like this :
1. First Binder The driver creates a data receiving buffer in kernel space ;
2. And then open a kernel cache in kernel space , Establish the mapping relationship between the kernel cache and the data receiving cache in the kernel , And the mapping relationship between the data receiving buffer and the user space address of the receiving process in the kernel ;
3. Sender process through system call copy from user() Put the data copy To the inside
Kernel cache in the kernel , Due to the memory mapping between the kernel cache and the user space of the receiving process , Therefore, it is equivalent to sending data to the user space of the receiving process , This completes a communication between processes .
边栏推荐
- Loop compensation - explanation and calculation of first-order, second-order and op amp compensation
- Harbor integrated LDAP authentication
- Pandaoxi's video
- MLX90614 driver, function introduction and PEC verification
- IDENTITY
- C3p0 connection MySQL 8.0.11 configuration problem
- How to quickly build high availability of service discovery
- . Net ADO splicing SQL statement with parameters
- Some 5000+ likes, the development notes of a director of cosmic factory, leaked
- How to solve the problem of computer networking but showing no Internet connection
猜你喜欢
Blue Bridge Cup -- Mason prime
Buuctf, misc: sniffed traffic
Pyqt5 sensitive word detection tool production, operator's Gospel
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
1 Introduction to spark Foundation
Ppt image processing
Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
Some 5000+ likes, the development notes of a director of cosmic factory, leaked
Leetcode: a single element in an ordered array
Qtoolbutton available signal
随机推荐
LeetCode 1646. Get the maximum value in the generated array
[actual combat record] record the whole process of the server being attacked (redis vulnerability)
Data consistency between redis and database
How to solve win10 black screen with only mouse arrow
Hcip day 16 notes
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
. Net ADO splicing SQL statement with parameters
Arc135 partial solution
C summary of knowledge point definitions, summary notes
How about opening an account at Hengtai securities? Is it safe?
Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Exclusive download! Alibaba cloud native brings 10 + technical experts to bring "new possibilities of cloud native and cloud future"
在恒泰证券开户怎么样?安全吗?
Format cluster and start cluster
Yyds dry goods inventory [practical] simply encapsulate JS cycle with FP idea~
Ansible common usage scenarios
[golang] leetcode intermediate - alphabetic combination of island number and phone number
How to quickly build high availability of service discovery
Sow of PMP