jos/user/fairness.c
Anish Athalye da1f8392b1 Lab 4
2018-10-08 21:32:14 -07:00

26 lines
465 B
C

// Demonstrate lack of fairness in IPC.
// Start three instances of this program as envs 1, 2, and 3.
// (user/idle is env 0).
#include <inc/lib.h>
void
umain(int argc, char **argv)
{
envid_t who, id;
id = sys_getenvid();
if (thisenv == &envs[1]) {
while (1) {
ipc_recv(&who, 0, 0);
cprintf("%x recv from %x\n", id, who);
}
} else {
cprintf("%x loop sending to %x\n", id, envs[1].env_id);
while (1)
ipc_send(envs[1].env_id, 0, 0, 0);
}
}