#include "ns.h" void timer(envid_t ns_envid, uint32_t initial_to) { int r; uint32_t stop = sys_time_msec() + initial_to; binaryname = "ns_timer"; while (1) { while((r = sys_time_msec()) < stop && r >= 0) { sys_yield(); } if (r < 0) panic("sys_time_msec: %e", r); ipc_send(ns_envid, NSREQ_TIMER, 0, 0); while (1) { uint32_t to, whom; to = ipc_recv((int32_t *) &whom, 0, 0); if (whom != ns_envid) { cprintf("NS TIMER: timer thread got IPC message from env %x not NS\n", whom); continue; } stop = sys_time_msec() + to; break; } } }