* more re-work
[mascara-docs.git] / i386 / junos / MIT / course / src / src.lab / net / timer.c
blob9708379f5189813c4533d8ab1bcfca4855de6f5c
1 #include "ns.h"
3 void
4 timer(envid_t ns_envid, uint32_t initial_to) {
5 int r;
6 uint32_t stop = sys_time_msec() + initial_to;
8 binaryname = "ns_timer";
10 while (1) {
11 while((r = sys_time_msec()) < stop && r >= 0) {
12 sys_yield();
14 if (r < 0)
15 panic("sys_time_msec: %e", r);
17 ipc_send(ns_envid, NSREQ_TIMER, 0, 0);
19 while (1) {
20 uint32_t to, whom;
21 to = ipc_recv((int32_t *) &whom, 0, 0);
23 if (whom != ns_envid) {
24 cprintf("NS TIMER: timer thread got IPC message from env %x not NS\n", whom);
25 continue;
28 stop = sys_time_msec() + to;
29 break;