Dynamic creation and passing of IPC channels
Björn Döbel
doebel at os.inf.tu-dresden.de
Mon Nov 25 20:21:07 CET 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Robert,
> I have two tasks running and communicating through an IPC
> connection (basically the clntsrv demo). Now I would like to extend
> this a bit:
>
>
> Using an ipc_call(), the client (actually: multiple clients) should
> be able to register with a server to receive a wakeup IPC at
> individually different points in time in the future.
>
> (First, flawed idea to do this was to *not* use the combined
> reply_and_wait call on the server side but instead to only do a
> wait() call and then postpone the corresponding reply() until when
> the client should be woken up. However, I learned that this will
> not work because the implicit reply capability will be lost as soon
> as another ipc call is done by the server.)
>
> Next idea now is to create another IPC channel in the client and to
> pass (via IPC) the send capability for that channel to the server.
> The client shall than block in an ipc_receive() on that channel and
> the server can wake it by sending to that channel. I guess this
> should be possible and for a seasoned Fiasco.OC/L4Re expert it is
> probably quite easy to do, but I can't seem to find how to:
>
> - create an IPC channel at client/server run time (so far, all IPC
> channels I used were prepared by Ned through lua scripts)
IPC channels (aka IPC gates) can be created using the
l4_factory_create_gate() method (or its C++ sibling
L4Re::Env::env()->factory()->create_gate()).
* During creation you bind() a thread to this gate. This is the
thread that is then allowed to receive messages through it.
* Anyone possessing a capability to the gate may send messages.
> - pass the send capability for such a channel to another task via
> IPC
Capabilities are passed around through standard IPC. The difference is
that you don't put them into the UTCB's message registers but instead
you out a send flexpage into the UTCB buffer registers. Note, that the
receiver must be willing to receive and therefore has to add a receive
flexpage on its side beforehand.
> Can anyone point me to some helpful documentation or maybe an
> example I could cannibalize to implement this (preferably in C, but
> C++ code would surely be helpful too)?
Unfortunately, there's no example that does exactly what you want. But
you might want to look at the following two:
* l4/pkg/examples/libs/l4re/streammap demonstrates delegation of
resources (memory pages in this case) from a server to a client.
Sending cap fpages is similar - you basically replace Rcv_fpage::mem()
with Rcv_fpage::obj() etc.
* l4/pkg/examples/libs/l4re/c++/clntsrv_ns is an adaptation of
l4/pkg/examples/clntsrv that passes capabilities the other way round.
The client creates an IPC gate, sends it to the server through an L4Re
namespace, and the server then obtains this channel and binds a
server-side thread to receive messages through this channel.
Cheers,
Bjoern
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/
iEYEARECAAYFAlKToyMACgkQP5ijxgQLUNmrxQCfZGC28zl5vitR9JYqWig/8GgK
M+UAn2p5jpLelPm2qFKk7H5ut0qZsfp3
=QIe4
-----END PGP SIGNATURE-----
More information about the l4-hackers
mailing list