Sharing memory between applications, client side.
#include <l4/sys/cache.h>
#include <cstring>
#include <cstdio>
#include <unistd.h>
#include "interface.h"
int main()
{
{
printf("Could not get the server capability\n");
return 1;
}
{
printf("Could not get capability slot!\n");
return 1;
}
{
printf("Could not get capability slot!\n");
return 1;
}
if (svr->get_shared_buffer(ds, irq))
{
printf("Could not get shared memory dataspace!\n");
return 1;
}
char *addr = 0;
if (err < 0)
{
printf("Error attaching data space: %s\n", l4sys_errtostr(err));
return 1;
}
printf("Content: %s\n", addr);
printf("Sleeping a bit...\n");
sleep(1);
memset(addr, 0, ds->
size());
char const * const msg = "Hello from client, too!";
printf("Setting new content in shared memory\n");
snprintf(addr, strlen(msg)+1, msg);
(unsigned long)addr + strlen(msg) + 1);
if (err)
printf("Failed to detach region\n");
return 0;
}