Talking about binder-series 2

One: Introduction

In the entire Android system, all applications are spliced ​​by one or more of the four major components in the Android system Activity, Service, Broadcast,ContentProvider

The bottom layer of the inter-process communication involved in these four components all depends on the Binder IPC communication mechanism. For example, when the Activity in process A wants to communicate with the Service in process B, it needs to rely on Binder IPC. Not only that,

In the entire Android system architecture, a large number of Binder mechanisms are used as IPC (inter-process communication) solutions, such as activity starting another activity, activity sending broadcast, etc. Of course, there are also some other IPC methods, such as

Zygote communication uses sockets. When clicking an app icon on the desktop to start the corresponding application (never opened it before), when AMS detects that there is no corresponding application process, it will initiate a socket request to

SystemServer process. At this time, SystemServer will use socket communication with Zygote process to create the corresponding application process. By default, the package name of this application will be used as the process name of this process, where the pid is given by

operating system to generate. The relationship between them can be shown in Figure 1 below. To understand the Binder mechanism in depth, we will sort out the whole process by reading the source code and drawing pictures.

 

                                            figure 1

 

(1) Question 1: Why does the communication between the SystemService process and the Zygote process use socket instead of the famous binder? Let's continue to study this issue in depth

When we were in high school, we learned a methodology in the biology class, the hypothetical deductive method, that is, when we are unclear about unknown problems or do not know how to start researching, we first assume one or several methods.

Conclusion, and then deduce from the conclusion, and finally get the correct answer.

Hypothesis 1: Does the communication between the SystemService process and the Zygote process use a socket mechanism with better performance than Binder?

We compared several methods of inter-process communication in the previous article on binder-series 1, and found that socket is not much superior to binder in terms of transmission performance and security. You can read the previous article

View, not discussed here.

Hypothesis 2: Could it be that Binder cannot be used in Zygote due to the sequence problem?

First I know, Service

Guess you like

Origin blog.csdn.net/qq_18757557/article/details/113981980