Hi,
Sounds good, though I expected the clients to write sampling data into the memory that is processed by the profiling server. More precisely, the server allocates the shared dataspace from its RAM session and provides the associated RAM-dataspace capability to its clients. Both
- client and server - attach the dataspace to their virtual memory
and, thereafter, share access to the same RAM pages.
So I've had a go at trying to implement a simpler case of having shared memory between two processes via adding code to the hello tutorial. I have done the following things:
- I added a dataspace capability variable in the session server (which contains the dispatch function) called net_buffer, and in the constructor, I allocate 4 bytes to the dataspace like so:
net_buffer = Genode::env()->ram_session()->alloc(4);
- In the session class, I added an extra virtual function declaration (get_cap()) to return the net_buffer variable.
- In the session client, I have an implementation of the get_cap function. In this function, I pass an opcode relating to returning the dataspace capability.
- In the component header, I have an implementation of get_cap() where i return net_buffer.
- The server source code is currently unchanged.
- I added code to the client source code to obtain the dataspace capability like so:
Dataspace_capability ds_cap = h.get_cap(); void *ptr = Genode::env()->rm_session()->attach(ds_cap);
And at the moment, I am able to write to ptr eg. an integer, and the value prints fine, for instance. In reference to what was said previously ie.
"Both - client and server - attach the dataspace to their virtual memory and, thereafter, share access to the same RAM pages."
How is the server meant to obtain the dataspace capability? Also, I'm assuming what I've done above is correct in terms of having shared memory between the server and client. So if i've done something, I would love to know what I need to do to fix it.
Thanks Peter