30 #include <sys/types.h>
41 char* mempool_args[3];
44 char* toAddress(
char*);
45 void* virgo_cloud_malloc(
void*);
46 void* virgo_cloud_free(
void*);
47 void* virgo_cloud_get(
void*);
48 void* virgo_cloud_set(
void*);
49 struct virgo_mempool_args* parse_virgomempool_command_userspace(
char* mempoolFunction);
51 void* virgo_cloud_malloc(
void* args)
53 printf(
"virgo_cloud_mempool.c:Executing virgo_cloud_mempool on cloud node, Invoking virgo_cloud_malloc(), Writing to file opened by Kernel, Kernel Space to User space communication works\n");
55 int size=atoi(vmargs->mempool_args[0]);
56 void* ptr=malloc(size);
57 printf(
"virgo_cloud_mempool.c:virgo_cloud_malloc(): ptr=%p\n",ptr);
62 void* virgo_cloud_get(
void* args)
64 printf(
"virgo_cloud_mempool.c:Executing virgo_cloud_mempool on cloud node, Invoking virgo_cloud_get(), Writing to file opened by Kernel, Kernel Space to User space communication works\n");
66 char* ptr=toAddress((
char*)vmargs->mempool_args[0]);
67 printf(
"virgo_cloud_mempool.c: virgo_cloud_get(): address=%p, data=%s\n",ptr,ptr);
71 void* virgo_cloud_set(
void* args)
73 printf(
"virgo_cloud_mempool.c:Executing virgo_cloud_mempool on cloud node, Invoking virgo_cloud_set(), Writing to file opened by Kernel, Kernel Space to User space communication works\n");
75 char* ptr=toAddress(vmargs->mempool_args[0]);
76 strcpy(ptr,strdup(vmargs->mempool_args[1]));
77 printf(
"virgo_cloud_mempool.c: virgo_cloud_set(): address=%p, data=%s\n",ptr,vmargs->mempool_args[1]);
81 void* virgo_cloud_free(
void* args)
83 printf(
"virgo_cloud_mempool.c:Executing virgo_cloud_mempool on cloud node, Invoking virgo_cloud_free(), Writing to file opened by Kernel, Kernel Space to User space communication works\n");
85 char* ptr=toAddress(vmargs->mempool_args[0]);
86 printf(
"virgo_cloud_mempool.c: virgo_cloud_free(): address=%p\n",ptr);
94 vmargs->mempool_cmd=strdup(strsep(&mempoolFunction,
"("));
95 if(strcmp(vmargs->mempool_cmd,
"virgo_cloud_malloc")==0 || strcmp(vmargs->mempool_cmd,
"virgo_cloud_free")==0)
97 vmargs->mempool_args[0]=strdup(strsep(&mempoolFunction,
")"));
98 vmargs->mempool_args[1]=NULL;
103 vmargs->mempool_args[0]=strdup(strsep(&mempoolFunction,
","));
104 vmargs->mempool_args[1]=strdup(strsep(&mempoolFunction,
")"));
105 vmargs->mempool_args[2]=NULL;
115 char* toAddress(
char* strAddress)
118 sscanf(strAddress,
"%p",ptr);