Android Binder interprocess communication mechanism 1-binder driver

Source: Internet
Author: User

Here are just a few outlines, to understand the details, also see the source code:

Affirmation: I rookie, hope to get the great God Guidance twos, more than heart foot has

Binder Equipment:/dev/binder

Binder interprocess communication involves four roles:

Client Service ServiceManager Binder Driver

One, binder driver

SOURCE Location: kernel/[vendor]/[codename]/drivers/staging/android/binder.c

Kernel/[vendor]/[codename]/drivers/staging/android/binder.h

and other related documents.

1. Basic data structure

struct Binder_work: Describes work items to be processed

struct Binder_node: Describes a binder entity object, in which each service component corresponds to a Binder entity object in the binder driver to describe its state in the kernel.

struct Binder_ref_death: Describes the death receive notification for a service component

struct Binder_ref: Describes a binder reference object, in which each client component should have a binder reference object in the binder driver to describe its state in the kernel.

struct Binder_buffer: Describes a kernel buffer that is used to transfer data between processes. Each process that uses the binder interprocess communication mechanism has a list of kernel buffers in the binder driver to hold the kernel buffers allocated by the binder driver.

struct Binder_proc: Used to describe a process that is using the binder communication mechanism, the binder driver creates the struct for the process when the process calls open/dev/binder.

struct Binder_thread: Describes a thread in the binder thread pool.

struct Binder_transaction: Describes interprocess communication processes

struct Binder_write_read: Describes the data transmitted during interprocess communication, including input and output data.

Enum Binderdrivercommandprotocol: A command protocol code that defines an input (binder drive) that is used when writing data to binder.

Enum Binderdriverreturnproctocol: Defines the return protocol code for the output (Binder drive), which is used when returning results from Binder read.

struct Binder_ptr_cookie: Describes the death receive notification for a Binder entity object or a service component.

Stuct Binder_transaction_data: Describes the data transferred during interprocess communication and is used as a parameter of the Command protocol code bc_transaction and bc_reply.

2.Binder Use process:

Initialization: Binder_init

Create the/proc/binder/proc directory on the target device

Each process that communicates using the binder mechanism has a corresponding file in that directory, which can be read to the binder thread pool of the process, Binder entity object, binder Reference object, and kernel buffer information.

The state states transactions Transaction_log Failed_taransaction_log file is also created to record the operation of the binder driver.

Binder Device Open: Binder_open

Create a BINDER_PROC structure for the process and add it to the global hash queue binder_procs.

Binder Device File Memory mapping: Binder_mmap

Allocates a kernel buffer for the process so that it can be used to transfer interprocess communication data.

3. Management of kernel buffers:

Allocating kernel buffers: binder_alloc_buf

Free kernel buffers: binder_free_buf

Query kernel buffers: binder_buffer_lookup

Android Binder interprocess communication mechanism 1-binder driver

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.