1*4d7e907cSAndroid Build Coastguard Worker1. Overview 2*4d7e907cSAndroid Build Coastguard Worker 3*4d7e907cSAndroid Build Coastguard WorkerA buffer pool enables processes to transfer buffers asynchronously. 4*4d7e907cSAndroid Build Coastguard WorkerWithout a buffer pool, a process calls a synchronous method of the other 5*4d7e907cSAndroid Build Coastguard Workerprocess and waits until the call finishes transferring a buffer. This adds 6*4d7e907cSAndroid Build Coastguard Workerunwanted latency due to context switching. With help from a buffer pool, a 7*4d7e907cSAndroid Build Coastguard Workerprocess can pass buffers asynchronously and reduce context switching latency. 8*4d7e907cSAndroid Build Coastguard Worker 9*4d7e907cSAndroid Build Coastguard WorkerPassing an interface and a handle adds extra latency also. To mitigate the 10*4d7e907cSAndroid Build Coastguard Workerlatency, passing IDs with local cache is used. For security concerns about 11*4d7e907cSAndroid Build Coastguard Workerrogue clients, FMQ is used to communicate between a buffer pool and a client 12*4d7e907cSAndroid Build Coastguard Workerprocess. FMQ is used to send buffer ownership change status from a client 13*4d7e907cSAndroid Build Coastguard Workerprocess to a buffer pool. Except FMQ, a buffer pool does not use any shared 14*4d7e907cSAndroid Build Coastguard Workermemory. 15*4d7e907cSAndroid Build Coastguard Worker 16*4d7e907cSAndroid Build Coastguard Worker2. FMQ 17*4d7e907cSAndroid Build Coastguard Worker 18*4d7e907cSAndroid Build Coastguard WorkerFMQ is used to send buffer ownership status changes to a buffer pool from a 19*4d7e907cSAndroid Build Coastguard Workerbuffer pool client. A buffer pool synchronizes FMQ messages when there is a 20*4d7e907cSAndroid Build Coastguard Workerhidl request from the clients. Every client has its own connection and FMQ 21*4d7e907cSAndroid Build Coastguard Workerto communicate with the buffer pool. So sending an FMQ message on behalf of 22*4d7e907cSAndroid Build Coastguard Workerother clients is not possible. 23*4d7e907cSAndroid Build Coastguard Worker 24*4d7e907cSAndroid Build Coastguard WorkerFMQ messages are sent when a buffer is acquired or released. Also, FMQ messages 25*4d7e907cSAndroid Build Coastguard Workerare sent when a buffer is transferred from a client to another client. FMQ has 26*4d7e907cSAndroid Build Coastguard Workerits own ID from a buffer pool. A client is specified with the ID. 27*4d7e907cSAndroid Build Coastguard Worker 28*4d7e907cSAndroid Build Coastguard WorkerTo transfer a buffer, a sender must send an FMQ message. The message must 29*4d7e907cSAndroid Build Coastguard Workerinclude a receiver's ID and a transaction ID. A receiver must send the 30*4d7e907cSAndroid Build Coastguard Workertransaction ID to fetch a buffer from a buffer pool. Since the sender already 31*4d7e907cSAndroid Build Coastguard Workerregistered the receiver via an FMQ message, The buffer pool must verify the 32*4d7e907cSAndroid Build Coastguard Workerreceiver with the transaction ID. In order to prevent faking a receiver, a 33*4d7e907cSAndroid Build Coastguard Workerconnection to a buffer pool from client is made and kept privately. Also part of 34*4d7e907cSAndroid Build Coastguard Workertransaction ID is a sender ID in order to prevent fake transactions from other 35*4d7e907cSAndroid Build Coastguard Workerclients. This must be verified with an FMQ message from a buffer pool. 36*4d7e907cSAndroid Build Coastguard Worker 37*4d7e907cSAndroid Build Coastguard WorkerFMQ messages are defined in BufferStatus and BufferStatusMessage of 'types.hal'. 38*4d7e907cSAndroid Build Coastguard Worker 39*4d7e907cSAndroid Build Coastguard Worker3. Interfaces 40*4d7e907cSAndroid Build Coastguard Worker 41*4d7e907cSAndroid Build Coastguard WorkerIConnection 42*4d7e907cSAndroid Build Coastguard WorkerA connection to a buffer pool from a buffer pool client. The connection 43*4d7e907cSAndroid Build Coastguard Workerprovides the functionalities to share buffers between buffer pool clients. 44*4d7e907cSAndroid Build Coastguard WorkerThe connection must be unique for each client. 45*4d7e907cSAndroid Build Coastguard Worker 46*4d7e907cSAndroid Build Coastguard WorkerIAccessor 47*4d7e907cSAndroid Build Coastguard WorkerAn accessor to a buffer pool which makes a connection to the buffer pool. 48*4d7e907cSAndroid Build Coastguard WorkerIAccesssor#connect creates an IConnection. 49*4d7e907cSAndroid Build Coastguard Worker 50*4d7e907cSAndroid Build Coastguard WorkerIClientManager 51*4d7e907cSAndroid Build Coastguard WorkerA manager of buffer pool clients and clients' connections to buffer pools. It 52*4d7e907cSAndroid Build Coastguard Workersets up a process to be a receiver of buffers from a buffer pool. The manager 53*4d7e907cSAndroid Build Coastguard Workeris unique in a process. 54*4d7e907cSAndroid Build Coastguard Worker 55