[Kernel Research] Binder framework overview, binder framework Overview

Source: Internet
Author: User

[Kernel Research] Binder framework overview, binder framework Overview

Binder. We often use pins to separate two sheets of paper. In Android, Binder is used to complete inter-process communication (IPC), that is, to separate multiple processes. For example, a common application can call the playing, pause, and stop functions provided by the music play service.

The Binder works on the Linux layer and belongs to a driver, but the driver does not need hardware, or the operating hardware is based on a small amount of memory. From the thread perspective, the Binder driver code runs in the kernel state, and the client program calls the Binder through the system call.


Binder is an architecture that provides three modules: server interface, Binder driver, and client interface ,.

First, let's look at the server. A Binder server is actually a Binder Class Object. Once this object is created, a hidden thread is started internally. The thread will then receive the message sent by the Binder driver. After receiving the message, it will execute the onTransact () function in the Binder object and execute different service code according to the parameter of the function. Therefore, to implement a Binder service, you must reload the onTransact () method.

As you can imagine, the main content of the heavy-duty onTransact () function is to convert the parameters of the onTransact () function to the parameters of the service function, while the parameter source of the onTransact () function is the client-side call of the transact () function () therefore, if there is a fixed format of input in transact (), onTransact () will have a fixed format of output.

Next, let's look at the Binder driver. When any server-side Binder object is created, an mRemote object is created in the Binder driver. The type of this object is also a Binder class. The client accesses the remote service through the mRemote object.


Finally, let's look at the application client. To access the remote service, the client must obtain the mRemote reference of the remote service in the Binder object. After obtaining the mRemote object, you can call its transact () method. In the Binder driver, the mRemote object also loads the transact () method. The overloaded content mainly includes the following items.

Send the parameters passed by the client to the server in the message communication mode between threads.

Suspends the current thread. The current thread is the client thread and waits until the server thread finishes executing the specified service function (notify ).

Receive notifications from the server thread, continue executing the client thread, and return to the client code area.

From this we can see that for application developers, the client seems to be directly calling the Binder corresponding to the remote service, but in fact it is transitioned through the Binder driver. There are two Binder objects. One is the Binder object of the server, and the other is the Binder object in the Binder driver. The difference is that the object in the Binder driver will not generate another thread.


Kernel-mode driver Framework Version 111 update, applicable to Windows 7 (KB2685811) How to keep installation failed?

Do you know why the installation fails! Because there are three patches that can easily cause blue screens, one of the three is the kernel-mode driver framework codenamed KB2685811, the installation fails only when Microsoft windows update has been intelligently ignored.
 
Tutorials on the Android kernel (especially the binder)

I started to read the kernel. I am still a beginner. Help you handle it, saving you trouble.
 

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.