14 static Channel* ctimer; /* chan(Timer*)[100] */
21 return nsec()/1000000;
41 int i, nt, na, dt, del;
45 threadsetname("timerproc");
52 sleep(1); /* will sleep minimum incr */
56 if(dt < 0) /* timer wrapped; go around, losing a tick */
67 * avoid possible deadlock if client is
68 * now sending on ctimer
70 if(nbsendul(x->c, 0) > 0)
74 memmove(&t[i], &t[i+1], (nt-i-1)*sizeof t[0]);
84 t = realloc(t, na*sizeof(Timer*));
86 error("timer realloc failed");
91 if(nbrecv(ctimer, &x) > 0)
99 ctimer = chancreate(sizeof(Timer*), 100);
100 proccreate(timerproc, nil, STACK);
112 t = emalloc(sizeof(Timer));
113 t->c = chancreate(sizeof(int), 0);