diff --git a/user/app1/appl.cc b/user/app1/appl.cc index 139e207..71e4754 100644 --- a/user/app1/appl.cc +++ b/user/app1/appl.cc @@ -6,25 +6,25 @@ char sbuf[8194], rbuf[8194]; // (2 * 4KiB) + 2 void main() { fork(); fork(); - int other = fork(); int ppid = sys_getpid(); - write(1, "app", 3, 0, ppid); - //if (ppid == other) { // child - // sbuf[0] = 3; - // sbuf[8192] = sys_getpid(); - // sbuf[8193] = 1; - // send(other, sbuf, 8193, rbuf, 8193); + int other = fork(); + //write(1, "app", 3, 0, ppid); + if (ppid == other) { // child + sbuf[0] = 3; + sbuf[8192] = sys_getpid(); + sbuf[8193] = 1; + send(other, sbuf, 8193, rbuf, 8193); - // char msg[] = "REPLY: AA\n"; - // msg[7] += rbuf[0] + sbuf[8193]; - // msg[8] += 4 + ppid; - // write(0, msg, 10); - //} else { // parent - // receive(rbuf, 8193); - // rbuf[0] = rbuf[0] + rbuf[8192]; - // rbuf[8193] = 7; - // reply(rbuf, 8193); - //} + char msg[] = "REPLY: AA\n"; + msg[7] += rbuf[0] + sbuf[8193]; + msg[8] += 4 + ppid; + write(0, msg, 10,0, ppid); + } else { // parent + receive(rbuf, 8193); + rbuf[0] = rbuf[0] + rbuf[8192]; + rbuf[8193] = 7; + reply(rbuf, 8193); + } sys_exit(); }