This commit is contained in:
Anish Athalye
2018-08-30 15:17:20 -04:00
commit 1a83673424
46 changed files with 5904 additions and 0 deletions

39
user/sendpage.c Normal file
View File

@@ -0,0 +1,39 @@
// Test Conversation between parent and child environment
// Contributed by Varun Agrawal at Stony Brook
#include <inc/lib.h>
const char *str1 = "hello child environment! how are you?";
const char *str2 = "hello parent environment! I'm good.";
#define TEMP_ADDR ((char*)0xa00000)
#define TEMP_ADDR_CHILD ((char*)0xb00000)
void
umain(int argc, char **argv)
{
envid_t who;
if ((who = fork()) == 0) {
// Child
ipc_recv(&who, TEMP_ADDR_CHILD, 0);
cprintf("%x got message: %s\n", who, TEMP_ADDR_CHILD);
if (strncmp(TEMP_ADDR_CHILD, str1, strlen(str1)) == 0)
cprintf("child received correct message\n");
memcpy(TEMP_ADDR_CHILD, str2, strlen(str2) + 1);
ipc_send(who, 0, TEMP_ADDR_CHILD, PTE_P | PTE_W | PTE_U);
return;
}
// Parent
sys_page_alloc(thisenv->env_id, TEMP_ADDR, PTE_P | PTE_W | PTE_U);
memcpy(TEMP_ADDR, str1, strlen(str1) + 1);
ipc_send(who, 0, TEMP_ADDR, PTE_P | PTE_W | PTE_U);
ipc_recv(&who, TEMP_ADDR, 0);
cprintf("%x got message: %s\n", who, TEMP_ADDR);
if (strncmp(TEMP_ADDR, str2, strlen(str2)) == 0)
cprintf("parent received correct message\n");
return;
}