IPC between native processes

3,662 views
Skip to first unread message

visa sansi

unread,
Feb 17, 2009, 2:15:22 AM2/17/09
to android-...@googlegroups.com
hi,

Is there a way to use Binder service for IPC between native processes? ( From my searches it seems the AIDL compiler is available for C++. )

If binder cannot be used between native processes for IPC, what is a the IPC mechanism that is supported? I see that standard message queues (mqueue.h) are not implemented in the kernel - Is this correct? ( cannot find implementaton for mq_open, mq_close etc... )

thanks
visansi

Dianne Hackborn

unread,
Feb 17, 2009, 2:59:50 AM2/17/09
to android-...@googlegroups.com
Yes, Binder is all in the native libraries, and the Java API is just a JNI wrapper around it.  The only limitations is that currently aidl doesn't know how to generate native interfaces, so you will need to write them by hand.  There are tons of examples in the tree, for example in Surface Flinger and various media interfaces and such.

That said, you can also use the trasitional Linux IPC facilities -- pipes and such.
--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support.  All such questions should be posted on public forums, where I and others can see and answer them.

visa sansi

unread,
Feb 17, 2009, 1:41:11 PM2/17/09
to android-...@googlegroups.com
Thanks for the prompt response.

Dianne Hackborn wrote :

>> That said, you can also use the trasitional Linux IPC facilities -- pipes and such.

I got fooled by the presence of mqueue.h in <and_root>/kernel/include/linux/mqueue.h - but it does not seem to expose any of the standard message queue APIs.. ( mq_open, mq_close ... )

I have begun re-writing my ipc using pipes for message based IPC ( what a pain packetizing the pipe interface.. :)

While I do that, can you please confirm that Android does not support linux message queues?

thanks
visansi

David Turner

unread,
Feb 17, 2009, 1:48:59 PM2/17/09
to android-...@googlegroups.com
I confirm that the Android C library doesn't support these message queue APIs :-)

Girish

unread,
Feb 17, 2009, 9:15:36 PM2/17/09
to android-platform
visansi,

I guess android only supports system V message queues, rather using
posix message queues try your luck with system V message queues.
Should work !

David Turner,
Any comments on this ?

Regards
Girish

On Feb 17, 11:48 pm, David Turner <di...@android.com> wrote:
> I confirm that the Android C library doesn't support these message queue
> APIs :-)
>

visa sansi

unread,
Feb 21, 2009, 11:14:52 PM2/21/09
to android-...@googlegroups.com
Thanks Girish, I was able to get system V message queues and pipes working in the emulator.

Girish

unread,
Mar 25, 2009, 11:44:48 PM3/25/09
to android-platform
Do pipes will supported or they will also be removed ?

chk this thread
http://groups.google.com/group/android-porting/browse_thread/thread/31747d788009c4a5

Regards
Girish

David Turner

unread,
Mar 26, 2009, 8:09:27 AM3/26/09
to android-...@googlegroups.com
Pipes don't have the problem of leaking so they are ok (and quite efficient these days too).

visa sansi

unread,
Mar 26, 2009, 11:16:18 PM3/26/09
to android-...@googlegroups.com
Thanks a tonne for bringing this to my attention Girish. Losing System V ipc will really put me behind. I need to guard against this fast.

I explored the Binder a bit and found it too risky without official AIDL compiler support for C++. There are a bunch of smartpointer objects are auto generated - which have to be manually coded without the AIDL compiler. And there is a maze of templates to manage also.

This is a big gaping hole in the native land in Android.

thanks again.
Visansi

Dianne Hackborn

unread,
Mar 27, 2009, 1:18:12 AM3/27/09
to android-...@googlegroups.com
On Thu, Mar 26, 2009 at 8:16 PM, visa sansi <vis...@gmail.com> wrote:
I explored the Binder a bit and found it too risky without official AIDL compiler support for C++. There are a bunch of smartpointer objects are auto generated - which have to be manually coded without the AIDL compiler. And there is a maze of templates to manage also.

That's not true.  The C++ API uses smart pointers so you don't have to do any reference counting yourself.  It's easier than managing the allocation of the objects manually.

Without the AIDL compiler you need to manually write the code to marshall/unmarshall function calls; no smart pointers or other such stuff.  Yes, it is something new to learn, but it is really not that complicated.
 
This is a big gaping hole in the native land in Android.

The primary IPC mechanism on android is Binder, which many native parts of the system use.  I honestly don't see how it can be any rougher than sys v primitives, unless you have some kind of interface compiler for those?  Otherwise hand-writing binder IPC code vs. sys v code is not all that different...  except at the end of the day the binder stuff will probably be a lot easier after you aren't doing it for the first time.

visa sansi

unread,
Mar 27, 2009, 1:53:58 AM3/27/09
to android-...@googlegroups.com

Chen Yang

unread,
Mar 31, 2009, 3:08:03 AM3/31/09
to android-...@googlegroups.com
hi Dianne:
I am interested to know where the updated document of Binder is and
where to begin from? I am not new to sys v code, but completely new to
binder. Thanks.
--
Chen

Dianne Hackborn

unread,
Mar 31, 2009, 3:40:01 AM3/31/09
to android-...@googlegroups.com
Sorry I didn't know there was Binder documentation at all, let alone updated documentation. :}  There have been a number of discussions on this and/or the android-framework group on Binder, and lots of example code you can find in the platform.  I have had an item on my to-do list for a long time to write Binder docs, but unfortunately haven't had a chance to do it yet.
Reply all
Reply to author
Forward
0 new messages