Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the ordering guarantees of AIDL "oneway" remote calls?

AIDL methods and interfaces marked with the "oneway" keyword are asynchronous Binder calls for remote processes, and it is said that the ordering of the calls is not guaranteed. On the other hand, the last comment of Dianne Hackborn (author of Binder) in this thread ( https://groups.google.com/forum/#!topic/android-developers/FFY-hg2Jx0M) says:

"ordering of delivery is tied to the target object (so you can receive calls on different interfaces out of order)"

Which seems to suggest, that calls to the same interface keep their order.

Can anyone clarify this?

like image 617
br1 Avatar asked Dec 08 '22 10:12

br1


1 Answers

As a general rule, oneway calls are asynchronous and can be dispatched on different threads concurrently with no ordering guarantees. However, the system imposes special ordering guarantees on oneway calls happening on the same IBinder object: in this case the transactions will be dispatched one at a time, in order of the original calls. Note that this ordering only applies in the specific case of oneway calls on the same IBinder object. Anything else -- calls on different IBinder objects or mixing oneway and sync calls -- will not give you any ordering guarantees between them.

The way this work is that in the kernel each IBinder object has a queue of oneway transactions to dispatch. A oneway call adds to that queue (a non-oneway call bypasses the queue). Transactions are dispatched out of the queue one at a time, as each previous transaction completes. So you may see these calls being dispatched on different threads, but the system makes sure that only one is executing at a time. (Again only for a single IBinder object, oneway calls on two different IBinder objects can execute concurrently.)

like image 189
hackbod Avatar answered Feb 22 '23 23:02

hackbod