In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
IBinder is the basic interface of remote objects and the core of a lightweight remote invocation mechanism designed for high performance. But it is used not only for remote calls, but also for in-process calls. This interface defines the protocol for interacting with remote objects. Instead of implementing this interface directly, you should derive it from Binder.
The main API of IBinder is transact (), and the other method corresponding to it is Binder.onTransact (). The first method allows you to send and make calls to the remote IBinder object, and the second method enables your own remote objects to respond to received calls. The API of IBinder is executed synchronously, for example, transact () does not return until the other party's Binder.onTransact () method call is complete. This is undoubtedly the case when the call occurs within a process, and it has the same effect between processes with the help of IPC.
The data sent through transact () is that Parcel,Parcel is a generic buffer with some metadata that describes its content in addition to the data. Metadata is used to manage references to IBinder objects so that they can be saved when buffers are moved from one process to another. This ensures that when an IBinder is written to Parcel and sent to another process, if another process posts back a reference to the same IBinder to the original process, the original process will receive a reference to the issued IBinder. This mechanism allows IBinder and Binder to be managed between processes as unique identifiers.
The system maintains a thread pool for each process to store interactive threads. These interactive threads are used to dispatch all IPC calls from another process. For example, when an IPC is sent from process A to the calling thread in process BMaga (which should not be in the thread pool), it is blocked in transact (). A thread in the interactive thread pool in process B receives the call, calls Binder.onTransact (), and returns the result with a Parcel. The waiting thread in process An is then able to continue execution after receiving the returned Parcel. In fact, another process looks like a thread of the current process, but it is not created by the current process.
The Binder mechanism also supports recursive calls between processes. For example, if process An executes its own IBinder's transact () to call process B's Binder, and process B initiates a call to process A with transact () in its Binder.onTransact (), process A responds to process B's transact () with Binder.onTransact () while waiting for its call to return. In short, the result of Binder is to make us feel that cross-process calls are no different from intra-process calls.
When manipulating remote objects, you often need to check to see if they are valid. There are three ways to use them:
The 1 transact () method throws a RemoteException exception if the process in which the IBinder resides does not exist.
2 if the target process does not exist, false is returned when pingBinder () is called.
3 you can register an IBinder.DeathRecipient with IBinder with the linkToDeath () method, which is called when the process represented by IBinder exits.
For more information about ibinder, please click on the → www.neitui.me/zx/.
Expert question and answer-Internet industry experience exchange platform → www.neitui.me/dkc/
Internal push Network (www.neitui.me), which focuses on making internal recommendations in the Internet recruitment industry, and creating the most professional internal recommendation platform for Internet recruitment.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.