Writing to two different dataspaces at the same time

Martin Stein martin.stein at ...1...
Thu Jan 21 12:25:07 CET 2016

Hi David,

Am 20.01.2016 um 23:42 schrieb David Werner:
> 1) Is it somehow possible to back a virtual address range with two 
> different dataspaces (attaching two different dataspaces at the same 
> virtual address is obviously not possible) ? What i want to achieve is 
> that writing to a virtual address results in writing to two dataspaces 
> at the same time, so that the dataspaces have the same content.

The only way I see to do this is by using a managed dataspace combined
with instruction emulation. But before going deeper into this: I wonder
why you want to access two dataspace at a time anyway?

A managed dataspace is not backed by physical memory but by another
virtual address range (see [2]). So, you can install your own region
manager implementation that is then called each time someone causes a
page fault on the managed dataspace. In your region manager you could
then resolve the faulting instruction to a double access. In order to do
so, your region manager would have to be able to access the text segment
of the component that uses the managed dataspace.

> 2) As far as i know a thread has to be added to a rm session as a client 
> in order to be able to use it as layout for its virtual address space. 

Not exactly. A thread can access any virtual address in the address
space of its component, without the need for a registration at the
corresponding RM session, *as long as the accessed address is already
mapped*. Rm_session::add_client is only needed to enable the handling of
page faults for a thread. It requests the RM session to create a a pager
for the thread and returns a capability that references this pager (see
[3]). To ensure that page faults of the thread are actually forwarded to
this pager, you have to call Cpu_session::set_pager(thread_cap,
pager_cap) additionally.

However, as virtual addresses are normally mapped on demand, one should
assume to cause page faults when accessing virtual addresses and thus
register its thread for page-fault handling in advance.

> Is it possible for a thread to operate on two different rm_sessions at 
> the same time?

Yes and no. You can call Rm_session::add_client for one thread on two
different RM sessions. What this does is that both RM sessions keep
ready a pager for the thread but the thread is linked to neither of them
yet. The linkage is done by Cpu_session::set_pager. As you can see for
example in [1], Cpu_session::set_pager simply overwrites the previous
configuration. So, if you call it twice with different pagers, your
thread will be linked to the pager you stated last.

But yes, you can incorporate multiple RM sessions into one address space
by the means of the already mentioned managed dataspaces. You would then
have to register your thread at the top-level RM session. However, also
in this case, each address goes down to exactly one "leaf" RM session
that is responsible for the corresponding faults.



[2] http://genode.org/documentation/genode-foundations-15-05.pdf Page
63, "Realizing managed dataspaces"


More information about the users mailing list