SlideShare a Scribd company logo
4
Most read
10
Most read
16
Most read
Understanding Binder in Android 
Haifeng Li 
2014-9-2
Outline 
•Background 
–What is Binder 
–Binder Communication Model 
–Terminology 
–Binder Software Stack 
•Client(user space) 
•Binder driver (Kernel Space) 
•Service(user space)
Background 
•What is Binder? 
–An Inter-process communication system for developing object-oriented OS services. 
clientserverData
Binder Communication Model 
User SpaceKernel SpaceCclientserviceBinder Driverioctl/open/...ioctl/open/... mInmOutioctl/open/... mInmOutmInmOutService Manager/system/bin/servicemanagerCGet ServiceAdd ServiceService 1 – handle 1Service 2 – handle 2...
Terminology 
•Service Handle 
•Remote Binder 
•Local Binder 
•Binder node 
•Binder reference 
•Service Manager(Context Manager) 
–It’s handle is 0 in all binder client and server. 
Binder DriverRemote Binder/HandleLocal BinderBinder NodeBinder ref.
IPC Software Stack 
App1 service 
Proxy(BpBinder) Stub(BnBinder) 
IPCThreadState IPCThreadState 
Binder Module 
User Space 
Kernel Space 
Client Server 
1 
2 
3 4 
5 
6 
1. BpBinder(n) -> transact(OP, data, &reply) 
2. IPCThreadState::transact(handle, OP, data, reply) 
3. ioctl(binder_fd, BINDER_OPERATION, &bwr) 
4. IPCThreadState::getAndExecuteCommand() 
5. Bnxxx::onTransact(OP, data, reply)
Client(user space) 
• Initialization 
– Call system call open(), which is binder_open in kernel. Open /dev/binder file 
and get a file description. Create some key data structures. 
– mmap 1MB-8KB virtual space for data transaction by binder_mmap in kernel. 
• Get handle of service from service manager 
• Sent request to Service by BpBinder(handle) 
• Data transact to kernel by IPCThreadState. 
App1 service 
Proxy(BpBinder) Stub(BnBinder) 
IPCThreadState IPCThreadState 
Binder Module 
User Space 
Kernel Space 
Client Server 
1 
2 
3 4 
5 
6
Data Transaction in Client(1) 
•Package in Client 
102 virtual void Client::Foo(int32_t push_data) { 
103 Parcel data, reply; 
104 data.writeInterfaceToken(IDemo::getInterfaceDescriptor()); 
105 data.writeInt32(push_data);//writeStrongBinder(service) 
109 
110 remote()->transact(OP, data, &reply); 
Parcel...flat_binder_objectmDataflat_binder_objectmObjectsService
Data Transaction in Client(2) 
•Packaged to binder_transaction_data 
IPCThreadState::writeTransactionData(int32_t cmd, …, int32_t handle, uint32_t code, const Parcel& data…) 
•cmd will add to mData.(BC_TRANSACTION, BC_REPLY,… Binder Command) 
•Target: target handle 
•Cookie: will be define according to handle in binder driver 
•Code: Operation of client. 
•Offsets could help the binder driver to process binder object reference. 
Parcel...flat_binder_objectmDataflat_binder_objectmObjectstargetcookiecode... data.ptr.bufferdata.ptr.offsets... binder_transaction_data
Data Transaction in Client(3) 
•Binder Command(User->Driver) 
–Binder Thread Support: BC_REGISTER_LOOPER, BC_ENTER LOOPER,BC_EXIT_LOOPER 
–Binder Transactions: BC_TRANSACTION, BC_REPLY 
–Further Mechanism: BC_INCREFS, BC_RELEASE , BC_DECREFS, BC_REQUEST_DEATH_NOTIFICIATION, BC_CLEAR_DEATH_NOTIFICATION, BC_DEAD_BINDER_DONE,… 
•Binder Return Command (Driver -> User) 
–Binder Thread Support: BR_SPAWN_LOOPER 
–Binder Transactions: BR_TRANSACTION, BR_REPLY 
–Further Mechanism: BR_INCREFS,BR_ACQUIRE, BR_RELEASE , BR_DECREFS, BR_CLEAR_DEATH_NOTIFICATION_DONE, … 
ClientServerDriverBC_TRANSACTIONBR_TRANSACTIONBC_REPLYBR_REPLYBC_FREE_BUFFERBC_FREE_BUFFER
Data Transaction in Client(4) 
•Repackage to Parcel(mOut) 
•Each working thread has two parcel: mOut and mIn. mOut is for write buffer, mIn for read buffer. 
Parcelcmdbinder_transactin_datamDatawrite_sizeWrite_bufferRead_sizeRead_bufferbinder_write_read
Outline 
•Background 
•Client(user space) 
•Binder driver (Kernel Space) 
•Service(user space) App1 service 
Proxy(BpBinder) Stub(BnBinder) 
IPCThreadState IPCThreadState 
Binder Module 
User Space 
Kernel Space 
Client Server 
1 
2 
3 4 
5 
6
Binder Driver:Binder Protocol 
•The protocol used for ioctl() system call. 
–BINDER_WRITE_READ 
–BINDER_SET_MAX_THREADS 
–BINDER_SET_CONTEXT_MGR 
–BINDER_THREAD_EXIT 
–BINDER_VERSION 
–BINDER_SET_IDLE_TIMEOUT
Key Data Structure (1) 
Binder Driver 
Process 1 Process 2 Process 3 
binder_proc binder_proc binder_proc 
threads node refs_by_desc refs_by_node 
• The binder_proc is mapped to process by 1:1. It is created on binder_open(). 
• All binder_proc are listed in binder_procs. 
• The binder_proc has 4 red-black tree. 
• The binder_thread represents a working thread, inserted into threads rbtree. 
• The binder_node represents a service, inserted into node rbtree. 
• refs_by_desc and refs_by_node represent reference to a proc_node.
Key Data Structure (2) 
User spaceKernel spaceBpBinderRemote BinderBBinderLocal Binderbinder_procnoderefs_by_nodebinder_procnoderefs_by_nodebinder_refbinder_node
Key Data Structure (3) 
... todothreadbinder_procbinder_threadtodobinder_workbinder_workbinder_workbinder_work... ... binder_transactionbinder_transaction
Input Data Format 
ParcelParcelwrite_sizewrite_bufferread_sizeread_bufferbinder_write_readbufferdata_sizeoffsets... binder_transaction_datacodecookiehandleoffset 1offset 2... ... flat_binder_objectflat_binder_objectBC_TRANSACTIONBC_XXXXxxx data structmOut... headIPCThreadStateClient
Transaction in Binder – Client (1) 
1. Copy binder_write_read from user space 
2. Copy xxx data to kernel space. Iterate the items: 
① Get Binder command from write_buffer(BC_XXX). 
② Get target thread/proc/node by handle. 
③ Allocate binder_buffer from target space, and copy effective data. 
④ Build a session(build_transaction). 
⑤ Mount the session to target_thread’s todo list. 
⑥ Mount a BINDER_WORK_TRANSACTION_COMPLETE binder_work to source thread 
⑦ Wake up corresponding thread. 
Parcel 
Parcel 
write_size 
write_buffer 
read_size 
read_buffer 
binder_write_read 
buffer 
data_size 
offsets 
... 
binder_transaction_data 
code 
cookie 
handle 
offset 1 
offset 2 
... 
... 
flat_binder_object 
flat_binder_object 
BC_TRANSACTION 
BC_XXX 
Xxxx data struct 
mOut 
... 
head 
IPCThreadState Client 
1 
2 
① 
② 
③
Transaction in Binder –Client (2) 
Target SpacedataCopyParcelParcelwrite_sizewrite_bufferread_sizeread_bufferbinder_write_readbufferdata_sizeoffsets... binder_transaction_datacodecookiehandleoffset 1offset 2... ... flat_binder_objectflat_binder_objectBC_TRANSACTIONBC_XXXXxxx data structmOut... headIPCThreadStateClientbufferpriorityoffsetssender_euidbinder_transactioncodeto_threadto_procdata... offsets_sizedata_sizetarget_nodebinder_bufferOffsets[] Copy
Transaction in Binder -- Server 
1.Server thread wake up and get a binder_work(binder_transaction) from todo list 
2.Build a binder_transaction_data from binder_transaction 
3.Set priority of current thread of client. 
4.The buffer and offsets will be virtual address 
–Virtual address = kernel address + address offset 
5.Copy binder_transaction_data to mIn 
6.Return from kernel 
7.IPCThreadState iternate the command and data. 
–For BR_TRANSACTION, call stub’s onTransact function, 
which will call server service function finally. 
Target Spacedatabufferpriorityoffsetssender_euidbinder_transactioncodeto_threadto_procdata... offsets_sizedata_sizetarget_nodebinder_bufferOffsets[] bufferdata_sizeoffsets... binder_transaction_datacodecookiehandle Kernel Space write_sizewrite_bufferread_sizeread_bufferbinder_write_readParcelmInBR_NOOPDatabinder_transaction_dataBR_TRANSACTIONCopy to user User Space
Transaction stack(1) 
•The stack is for recording transaction session. 
•Commonly, to_parent and from_parent is null. But, when the transaction rely on other session, what will happen? 
–The session in B will lost. 
A(list_head)todoBinder_thread BBinder_thread transaction_stackwait queue... (list_head)todotransaction_stackwait queue... to_parentfrom_parent... sender_euidbinder_transaction... to_threadtodo
Transaction stack(2) 
•For example, A -> B, B->C, C->A
Binder Workflow

More Related Content

PPTX
Binder: Android IPC
PDF
Low Level View of Android System Architecture
PPTX
Overview of Android binder IPC implementation
PDF
Android IPC Mechanism
PDF
Embedded Android : System Development - Part IV (Android System Services)
PPTX
Android Binder: Deep Dive
PDF
Android Things : Building Embedded Devices
PDF
Explore Android Internals
Binder: Android IPC
Low Level View of Android System Architecture
Overview of Android binder IPC implementation
Android IPC Mechanism
Embedded Android : System Development - Part IV (Android System Services)
Android Binder: Deep Dive
Android Things : Building Embedded Devices
Explore Android Internals

What's hot (20)

PDF
Booting Android: bootloaders, fastboot and boot images
PDF
Android's HIDL: Treble in the HAL
ODP
Embedded Android : System Development - Part III
PDF
Embedded Android : System Development - Part II (HAL)
PPT
Learning AOSP - Android Linux Device Driver
PPTX
U-boot and Android Verified Boot 2.0
PDF
Design and Concepts of Android Graphics
PDF
Embedded Android : System Development - Part II (Linux device drivers)
PDF
Android Internals
PPTX
Introduction of android treble
PDF
Understanding the Android System Server
PDF
Android binder introduction
PDF
Embedded Android Workshop
PDF
Embedded Android : System Development - Part I
PDF
Applied Computer Science Concepts in Android
PPT
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
PPTX
Android AIDL Concept
PDF
Embedded Android : System Development - Part IV
PPTX
Introduction to GItlab CICD Presentation.pptx
ODP
Q4.11: Porting Android to new Platforms
Booting Android: bootloaders, fastboot and boot images
Android's HIDL: Treble in the HAL
Embedded Android : System Development - Part III
Embedded Android : System Development - Part II (HAL)
Learning AOSP - Android Linux Device Driver
U-boot and Android Verified Boot 2.0
Design and Concepts of Android Graphics
Embedded Android : System Development - Part II (Linux device drivers)
Android Internals
Introduction of android treble
Understanding the Android System Server
Android binder introduction
Embedded Android Workshop
Embedded Android : System Development - Part I
Applied Computer Science Concepts in Android
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Android AIDL Concept
Embedded Android : System Development - Part IV
Introduction to GItlab CICD Presentation.pptx
Q4.11: Porting Android to new Platforms
Ad

Viewers also liked (6)

PDF
Understanding Monitor in Dalvik
PDF
Understanding DLmalloc
PDF
Understanding Semi-Space Garbage Collector in ART
PDF
Process Scheduler and Balancer in Linux Kernel
PDF
Understanding SLAB in Linux Kernel
PDF
AARCH64 VMSA Under Linux Kernel
Understanding Monitor in Dalvik
Understanding DLmalloc
Understanding Semi-Space Garbage Collector in ART
Process Scheduler and Balancer in Linux Kernel
Understanding SLAB in Linux Kernel
AARCH64 VMSA Under Linux Kernel
Ad

Similar to Understanding binder in android (20)

PDF
Android IPC Mechanism
PDF
Gene Hynson [InfluxData] | How We Built the MQTT Native Collector | InfluxDay...
PDF
Hyperledger Fabric Application Development 20190618
PPTX
Processing IoT Data with Apache Kafka
PDF
Introduction to enterprise applications capacity planning
PDF
From logs to metrics
PPTX
20131028 BTUG.be - BizTalk Tracking
PPTX
Cascon Decentralized IoT update - Blockchain and Smart Contracts
PDF
Python lecture 11
PPTX
Byte Ordering - Unit 2.pptx
PPTX
Citi TechTalk Session 2: Kafka Deep Dive
PDF
Sharding and things we'd like to see improved
PDF
16-bit Microprocessor Design (2005)
PDF
Create C++ Applications with the Persistent Memory Development Kit
PDF
MINA2 (Apache Netty)
PDF
Build an Edge-to-Cloud Solution with the MING Stack
PDF
Elements for an iOS Backend
PDF
Technical Report Vawtrak v2
Android IPC Mechanism
Gene Hynson [InfluxData] | How We Built the MQTT Native Collector | InfluxDay...
Hyperledger Fabric Application Development 20190618
Processing IoT Data with Apache Kafka
Introduction to enterprise applications capacity planning
From logs to metrics
20131028 BTUG.be - BizTalk Tracking
Cascon Decentralized IoT update - Blockchain and Smart Contracts
Python lecture 11
Byte Ordering - Unit 2.pptx
Citi TechTalk Session 2: Kafka Deep Dive
Sharding and things we'd like to see improved
16-bit Microprocessor Design (2005)
Create C++ Applications with the Persistent Memory Development Kit
MINA2 (Apache Netty)
Build an Edge-to-Cloud Solution with the MING Stack
Elements for an iOS Backend
Technical Report Vawtrak v2

Recently uploaded (20)

PPTX
Sustainable Sites - Green Building Construction
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
PPT on Performance Review to get promotions
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Construction Project Organization Group 2.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
bas. eng. economics group 4 presentation 1.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Current and future trends in Computer Vision.pptx
PDF
Digital Logic Computer Design lecture notes
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Artificial Intelligence
Sustainable Sites - Green Building Construction
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPT on Performance Review to get promotions
Lecture Notes Electrical Wiring System Components
Construction Project Organization Group 2.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
bas. eng. economics group 4 presentation 1.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
Current and future trends in Computer Vision.pptx
Digital Logic Computer Design lecture notes
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
CH1 Production IntroductoryConcepts.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Artificial Intelligence

Understanding binder in android

  • 1. Understanding Binder in Android Haifeng Li 2014-9-2
  • 2. Outline •Background –What is Binder –Binder Communication Model –Terminology –Binder Software Stack •Client(user space) •Binder driver (Kernel Space) •Service(user space)
  • 3. Background •What is Binder? –An Inter-process communication system for developing object-oriented OS services. clientserverData
  • 4. Binder Communication Model User SpaceKernel SpaceCclientserviceBinder Driverioctl/open/...ioctl/open/... mInmOutioctl/open/... mInmOutmInmOutService Manager/system/bin/servicemanagerCGet ServiceAdd ServiceService 1 – handle 1Service 2 – handle 2...
  • 5. Terminology •Service Handle •Remote Binder •Local Binder •Binder node •Binder reference •Service Manager(Context Manager) –It’s handle is 0 in all binder client and server. Binder DriverRemote Binder/HandleLocal BinderBinder NodeBinder ref.
  • 6. IPC Software Stack App1 service Proxy(BpBinder) Stub(BnBinder) IPCThreadState IPCThreadState Binder Module User Space Kernel Space Client Server 1 2 3 4 5 6 1. BpBinder(n) -> transact(OP, data, &reply) 2. IPCThreadState::transact(handle, OP, data, reply) 3. ioctl(binder_fd, BINDER_OPERATION, &bwr) 4. IPCThreadState::getAndExecuteCommand() 5. Bnxxx::onTransact(OP, data, reply)
  • 7. Client(user space) • Initialization – Call system call open(), which is binder_open in kernel. Open /dev/binder file and get a file description. Create some key data structures. – mmap 1MB-8KB virtual space for data transaction by binder_mmap in kernel. • Get handle of service from service manager • Sent request to Service by BpBinder(handle) • Data transact to kernel by IPCThreadState. App1 service Proxy(BpBinder) Stub(BnBinder) IPCThreadState IPCThreadState Binder Module User Space Kernel Space Client Server 1 2 3 4 5 6
  • 8. Data Transaction in Client(1) •Package in Client 102 virtual void Client::Foo(int32_t push_data) { 103 Parcel data, reply; 104 data.writeInterfaceToken(IDemo::getInterfaceDescriptor()); 105 data.writeInt32(push_data);//writeStrongBinder(service) 109 110 remote()->transact(OP, data, &reply); Parcel...flat_binder_objectmDataflat_binder_objectmObjectsService
  • 9. Data Transaction in Client(2) •Packaged to binder_transaction_data IPCThreadState::writeTransactionData(int32_t cmd, …, int32_t handle, uint32_t code, const Parcel& data…) •cmd will add to mData.(BC_TRANSACTION, BC_REPLY,… Binder Command) •Target: target handle •Cookie: will be define according to handle in binder driver •Code: Operation of client. •Offsets could help the binder driver to process binder object reference. Parcel...flat_binder_objectmDataflat_binder_objectmObjectstargetcookiecode... data.ptr.bufferdata.ptr.offsets... binder_transaction_data
  • 10. Data Transaction in Client(3) •Binder Command(User->Driver) –Binder Thread Support: BC_REGISTER_LOOPER, BC_ENTER LOOPER,BC_EXIT_LOOPER –Binder Transactions: BC_TRANSACTION, BC_REPLY –Further Mechanism: BC_INCREFS, BC_RELEASE , BC_DECREFS, BC_REQUEST_DEATH_NOTIFICIATION, BC_CLEAR_DEATH_NOTIFICATION, BC_DEAD_BINDER_DONE,… •Binder Return Command (Driver -> User) –Binder Thread Support: BR_SPAWN_LOOPER –Binder Transactions: BR_TRANSACTION, BR_REPLY –Further Mechanism: BR_INCREFS,BR_ACQUIRE, BR_RELEASE , BR_DECREFS, BR_CLEAR_DEATH_NOTIFICATION_DONE, … ClientServerDriverBC_TRANSACTIONBR_TRANSACTIONBC_REPLYBR_REPLYBC_FREE_BUFFERBC_FREE_BUFFER
  • 11. Data Transaction in Client(4) •Repackage to Parcel(mOut) •Each working thread has two parcel: mOut and mIn. mOut is for write buffer, mIn for read buffer. Parcelcmdbinder_transactin_datamDatawrite_sizeWrite_bufferRead_sizeRead_bufferbinder_write_read
  • 12. Outline •Background •Client(user space) •Binder driver (Kernel Space) •Service(user space) App1 service Proxy(BpBinder) Stub(BnBinder) IPCThreadState IPCThreadState Binder Module User Space Kernel Space Client Server 1 2 3 4 5 6
  • 13. Binder Driver:Binder Protocol •The protocol used for ioctl() system call. –BINDER_WRITE_READ –BINDER_SET_MAX_THREADS –BINDER_SET_CONTEXT_MGR –BINDER_THREAD_EXIT –BINDER_VERSION –BINDER_SET_IDLE_TIMEOUT
  • 14. Key Data Structure (1) Binder Driver Process 1 Process 2 Process 3 binder_proc binder_proc binder_proc threads node refs_by_desc refs_by_node • The binder_proc is mapped to process by 1:1. It is created on binder_open(). • All binder_proc are listed in binder_procs. • The binder_proc has 4 red-black tree. • The binder_thread represents a working thread, inserted into threads rbtree. • The binder_node represents a service, inserted into node rbtree. • refs_by_desc and refs_by_node represent reference to a proc_node.
  • 15. Key Data Structure (2) User spaceKernel spaceBpBinderRemote BinderBBinderLocal Binderbinder_procnoderefs_by_nodebinder_procnoderefs_by_nodebinder_refbinder_node
  • 16. Key Data Structure (3) ... todothreadbinder_procbinder_threadtodobinder_workbinder_workbinder_workbinder_work... ... binder_transactionbinder_transaction
  • 17. Input Data Format ParcelParcelwrite_sizewrite_bufferread_sizeread_bufferbinder_write_readbufferdata_sizeoffsets... binder_transaction_datacodecookiehandleoffset 1offset 2... ... flat_binder_objectflat_binder_objectBC_TRANSACTIONBC_XXXXxxx data structmOut... headIPCThreadStateClient
  • 18. Transaction in Binder – Client (1) 1. Copy binder_write_read from user space 2. Copy xxx data to kernel space. Iterate the items: ① Get Binder command from write_buffer(BC_XXX). ② Get target thread/proc/node by handle. ③ Allocate binder_buffer from target space, and copy effective data. ④ Build a session(build_transaction). ⑤ Mount the session to target_thread’s todo list. ⑥ Mount a BINDER_WORK_TRANSACTION_COMPLETE binder_work to source thread ⑦ Wake up corresponding thread. Parcel Parcel write_size write_buffer read_size read_buffer binder_write_read buffer data_size offsets ... binder_transaction_data code cookie handle offset 1 offset 2 ... ... flat_binder_object flat_binder_object BC_TRANSACTION BC_XXX Xxxx data struct mOut ... head IPCThreadState Client 1 2 ① ② ③
  • 19. Transaction in Binder –Client (2) Target SpacedataCopyParcelParcelwrite_sizewrite_bufferread_sizeread_bufferbinder_write_readbufferdata_sizeoffsets... binder_transaction_datacodecookiehandleoffset 1offset 2... ... flat_binder_objectflat_binder_objectBC_TRANSACTIONBC_XXXXxxx data structmOut... headIPCThreadStateClientbufferpriorityoffsetssender_euidbinder_transactioncodeto_threadto_procdata... offsets_sizedata_sizetarget_nodebinder_bufferOffsets[] Copy
  • 20. Transaction in Binder -- Server 1.Server thread wake up and get a binder_work(binder_transaction) from todo list 2.Build a binder_transaction_data from binder_transaction 3.Set priority of current thread of client. 4.The buffer and offsets will be virtual address –Virtual address = kernel address + address offset 5.Copy binder_transaction_data to mIn 6.Return from kernel 7.IPCThreadState iternate the command and data. –For BR_TRANSACTION, call stub’s onTransact function, which will call server service function finally. Target Spacedatabufferpriorityoffsetssender_euidbinder_transactioncodeto_threadto_procdata... offsets_sizedata_sizetarget_nodebinder_bufferOffsets[] bufferdata_sizeoffsets... binder_transaction_datacodecookiehandle Kernel Space write_sizewrite_bufferread_sizeread_bufferbinder_write_readParcelmInBR_NOOPDatabinder_transaction_dataBR_TRANSACTIONCopy to user User Space
  • 21. Transaction stack(1) •The stack is for recording transaction session. •Commonly, to_parent and from_parent is null. But, when the transaction rely on other session, what will happen? –The session in B will lost. A(list_head)todoBinder_thread BBinder_thread transaction_stackwait queue... (list_head)todotransaction_stackwait queue... to_parentfrom_parent... sender_euidbinder_transaction... to_threadtodo
  • 22. Transaction stack(2) •For example, A -> B, B->C, C->A