当前位置:网站首页>[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 .
边栏推荐
- Opengauss database log management guide
- 1068. Consolidation of ring stones (ring, interval DP)
- Summary of fluent systemchrome
- STM32 multi serial port implementation of printf -- Based on cubemx
- Hcip day 14 notes
- Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
- ADB command to get XML
- [flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
- Teach you how to run two or more MySQL databases at the same time in one system
- A preliminary study on the middleware of script Downloader
猜你喜欢

Data consistency between redis and database
![[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)](/img/b8/e2a59772d009b6ee262fb4807f2cd2.jpg)
[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)

Pan Yueming helps Germany's Rochester Zodiac custom wristwatch

Bufferpool caching mechanism for executing SQL in MySQL

Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet

QT creator source code learning note 05, how does the menu bar realize plug-in?

IDENTITY

Mysql database - Advanced SQL statement (I)

string

Go Technology Daily (2022-02-13) - Summary of experience in database storage selection
随机推荐
Apple released a supplementary update to MacOS Catalina 10.15.5, which mainly fixes security vulnerabilities
QT creator source code learning note 05, how does the menu bar realize plug-in?
[issue 16] golang's one-year experience in developing Purdue Technology
Blue Bridge Cup -- Mason prime
33 restrict the input of qlineedit control (verifier)
LeetCode 540. A single element in an ordered array
Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
How can enterprises and developers take advantage of the explosion of cloud native landing?
BUUCTF,Misc:LSB
How about agricultural futures?
Runtime. getRuntime(). totalMemory/maxMemory()
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Day30-t540-2022-02-14-don't answer by yourself
C summary of knowledge point definitions, summary notes
Overview of Yunxi database executor
How to solve win10 black screen with only mouse arrow
Opengauss database log management guide
Get current JVM data
[sg function] 2021 Niuke winter vacation training camp 6 h. winter messenger 2
User login function: simple but difficult