* same with xv6
[mascara-docs.git] / i386 / ucla / src / lab4 / user / fairness.c
blob696110571f3dd1a636a81613b30cce5b6dd4cc02
1 // Demonstrate lack of fairness in IPC.
2 // Start three instances of this program as envs 1, 2, and 3.
3 // (user/idle is env 0).
5 #include <inc/lib.h>
7 asmlinkage void
8 umain(int argc, char **argv)
10 envid_t who, id;
12 id = sys_getenvid();
14 if (thisenv == &envs[1]) {
15 while (1) {
16 ipc_recv(&who, 0, 0);
17 cprintf("%x recv from %x\n", id, who);
19 } else {
20 cprintf("%x loop sending to %x\n", id, envs[1].env_id);
21 while (1)
22 ipc_send(envs[1].env_id, 0, 0, 0);