Study Notes on inter-process communication mechanism of Android IPC

Source: Internet
Author: User

I. What methods does the Linux system use for inter-process communication?

1. Socket;

2. Name pipe name pipeline;

3. Message Queue;

4. Singal semaphore;

5. share memory shared memory;

 

2. What is the communication mode of the Java System?

1. Socket;

2. Name pipe;

 

3. What is the communication mode of the Android system?

Binder communication;

 

4. What are the advantages of binder communication?

High Efficiency

 

5. What are the characteristics of binder communication?

It is synchronous, not asynchronous;

 

6. How is binder communication implemented?

1. Binder communication is implemented through the Linux binder driver,

2. The binder communication operation is similar to threadmigration. The IPC between two processes is like a process entering another process to execute code and then returning the execution result;

3. The binder user space maintains an available thread pool for each process. The thread pool is used to process the incoming IPC and execute local messages of the process. The binder communication is synchronous rather than asynchronous.

 

VII. Key Points of binder communication in Android:

1. The binder communication in Android is based on the working model of the service and client;

2. All processes that need to communicate with ibinder must create an ibinder interface;

3. There is a system service managed by a process in the system:

4. Android does not allow users to add unauthorized systemservice;

5. Now the source code is open. We can modify some code to add the underlying system service;

6. For user programs, we also need to create server or service for inter-process communication;

7. activitymanagerservice manages connect and disconnect for all services at the Java application layer;

8. All activities are started and loaded through this service;

9. activitymanagerservice is also loaded in systems servcie;

 

8. Android Service Workflow

1. Before the android virtual machine starts, the system starts the Service Manager process. 2. The service manager opens the binder driver and notifies the binder kernel driver that the process will be used as the System Service Manager;

3. The process enters a loop and waits for data from other processes to be processed. 4. After creating a system service, you can use defaservicservicemanager to obtain a remote servicemanager interface. Through this interface, you can call the addservice function to add the system service to the Service Manager process;

5. Then the client can get the ibinder object of the target service to be connected through getservice, which is a reference of the Service bbinder in the binder kernel,

6. Therefore, serviceibinder does not have the same two ibinder objects in the binder kernel. Each client process also needs to open the binder driver. For user programs, we can obtain this object and access the methods in the service object through binderkernel.

7. in different processes, the client and Service implement the communication mode of migration between similar threads. For a user program, when the ibinder interface returned by the service is called, accessing a method in a service is like calling a function.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.